Wednesday, 11 March 2015

Programming PIC16F877A in Assembly

WREG (Working Register):

Working register is very important in PIC microcontroller all literal values used to perform arithmetic operation or to move into any port or file register first move into WREG than other function will perform. Similarly in PIC16F877A when we want to move a data from one port/register to another Port/register we have to move that data into WREG first and then move it into any other port/register.

Instruction set use in PIC16F877A:

The instruction set of PIC16F877A is split into 3 categories:
  1. Byte Oriented
  2. Bit Oriented
  3. Literal value and control operations

Byte Oriented Operations:


ADDWF:

Santax: ADDWF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to add data in working register and file register, destination of result of addition is control by 'd'
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

ANDWF:

Santax: ANDWF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to perform AND operation on data in working register and file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

CLRF:

Santax: CLRF f
f  => address of file register

Function: Use to clear file register.

CLRW:

Santax: CLRW

Function: Use to clear Working register.

COMF:

Santax: COMF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to take complement of file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

DECF:

Santax: DECF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to decrease one number from file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

DECFSZ:

Santax: DECFSZ f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to decrease one number from file register, and skip next instruction if result is equal to zero. Destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

INCF:

Santax: INCF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to increase one number from file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

INCFSZ:

Santax: INCFSZ f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to increase one number from file register, and skip next instruction if result is equal to zero. Destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

IORWF:

Santax: IORWF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to perform OR operation on data in working register and file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

MOVF:

Santax: MOVF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to move data in file register to working register, 
commonly d = W to move data in working register.

MOVWF:

Santax: MOVWF f
f  => address of file register.

Function: Use to move data from working register to file register.

NOP:

Santax: NOP
Function: perform no operation used to waste one instruction cycle.

RLF:

Santax: RLF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to move data in file register from right to left, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

RRF:

Santax: RRF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to move data in file register from left to right, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

SUBWF:

Santax: SUBWF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to subtract data in working register from file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

SWAPF:

Santax: SWAPF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to swap nibbles in file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.

XORWF:

Santax: XORWF f,d
f  => address of file register
d => use to save result in either working register or file register

Function: Use to perform XOR operation on data in working register and file register, destination of result is control by 'd'.
if d = W then result of addition is stored in Working register.
if d = F then result of addition is stored in File register.


No comments:

Post a Comment