Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science

The PIC family has a very short range of instructions. With just about 35 instructions, there may be times where you need to find complicated solutions for operations that you thought as standard, such as a division or multiplications for example, that there is no direct instruction for them.

All instructions have just about the same format. First comes the name of the instructions. Then, comes the instructions fields. The fields may be none, one or two, according to he instruction. They could be filled with wither a register file address (f), a bit address (b), a literal field, constant data or label (k) or a destination selection (d).

A register file address is a field that indicates the absolute position of a register within the RAM. This field could be filled with either a number (e.g. 0x05h for the PORTA register) or a register name, as long as this name has been previously declared.

Each byte is composed by bits. For the 8-bit PIC 16F88 that we use, each byte is composed by 8 bits. When a field requires a bit address, this means that a number from 0 to 7 must be placed. Number 0 corresponds to the Less Significant Bit (LSB) and it is the most right placed bit in within the byte. Number 7 on the other hand corresponds to the Most Significant Bit (MSB) and it is the most left placed bit in within the byte.

Literal field, constant data or label (k)

This field is generally a number. This number may be from a previous-defined constant data, or from a label within the code.

Destination selection (d)

This field can be either 0 or one. It is used in instructions that will return a byte as a result of an operation. The destination field will define where this byte will be stored. If this field is 0, then the byte will be stored in the working register (W). If the destination is 1, then the byte will be stored back to the register that the specific operation began. If the Microchip header file is included within your code, then you can directly write 'W' for 0 or 'F' for file register.

The W is the one and only Working Register that exists in the PIC 16 series. This is a 8-bit width register used for general operations. The W register will be your best friend and therefore you need to get used to it really quick. For example, there is no direct way to add a 8-bit number with ti a file register. Instead, you need first to load this number to the W register (using the movlw instruction) and then add the W register to the file register (using the addwf instruction).

Previous page ---- Next page

Go back to the book contents

Go to the discussion forum of this book

 At 17 August 2011, 12:28:59 user mohsen wrote:   [reply @ mohsen]hi i want totorial winding animation clip plz, tnxAt 12 January 2011, 10:28:58 user ashish vishwakarma wrote:   [reply @ ashish vishwakarma]how to write code for 16 bit PIC Microcontroller reset ?

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise without the prior written permission of the author.

All trademarks used are properties of their respective owners.

 HOT in heaven!

 Disclaimer Book Contents Discussion forum

 NEW in heaven! New Theory: AC electric motor working principle