SECTION III-6: DECF Instruction in the PIC micro-controller

The "DECF fileReg, d" instruction decrements (subtract one from) the contents of fileReg and places the result in WREG of fileReg.

Put the value into fileReg location 0x20. Then the value in location 0x20 is decremented and placed in fileReg.

MOVLW 3 ;WREG = 3
MOVWF 20H ;move WREG to location 20H (location 20H = 3)
DECF 0x20, F ;location 20H has 2  (WREG = 3)
DECF 0x20, F ;location 20H has 1  (WREG = 3)
DECF 0x20, F ;location 20H has 0  (WREG = 3)

 

 

 

 

 

Now, Compare the above code with the following below:-

MOVLW 3 ;WREG = 3
MOVWF 20H ;move WREG to location 20H (location 20H = 3)
DECF 0x20, W ;location 20H has 3  (WREG = 2)
DECF 0x20, W ;location 20H has 3  (WREG = 1)
DECF 0x20, W ;location 20H has 3  (WREG = 0)

 

 

 

 

More From Iamtechnical.com

Advertisement:

SiteLock