Microcontroller Operation:Single Register Operations

Single Register Operations

The processor operates on 8-bit data stored in RAM registers and W. The data can originate in three ways:

• A literal (numerical value) provided in the program

• An input via a port data register

• The result of a previous operation.

This data is processed using the set of instructions defined for that processor. Table 2.2

shows a typical set of operations that can be applied to a single register. The same binary number is shown before processing, and then after the operation has been applied to the register.

As an example of how these operations are specified in mnemonic form in the program, the hex and assembler code to increment a PIC register is:

0A86 INCF 06

Register number 06 happens to be port B data register, so the effect of this instruction can be seen immediately at I/O pins of the chip. The corresponding machine code instruction is 0A86h, or 00 1010 1000 0110 in binary (14 bits). As you can see, it is easier to recognize the mnemonic form. Bit 7 of the instruction code is significant in that it determines the destination of the result. The default is ‘1’, which causes the result to be left in the RAM register. ‘0’ places it in W, which helps to reduce the number of move instructions required.

An example of a single register operation appears at line 33 in the keypad program, CLRF PORTC, which sets all the output bits connected to the display to zero, switching it off.

PIC Microcontrollers-1133

Leave a comment

Your email address will not be published. Required fields are marked *