Write a code segment in assembly of PIC18 that implement the following instructions in C. Note: Variables are long type (4 bytes) Long i,j; i++; i--; j = i+j
Solution
org 0x0000 ; program starting address after reset
goto start
org 0x08
retfie ; high priority interrupt service routine
org 0x18
retfie ; low priority interrupt service routine
start mov.b #0, w0 ;WREG=0=0x64 Initializing the variable
mov.b WREG.0x0800 ; i=WREG
inc.b 0x0800 ;i=i++ or i=i+1
dec.b 0x801 ;j=j-1 or j—
sdd.b 0x0801, WREG ; WREG=j+WREG (ie j+i)
mov.b WREG, 0x0801 ;j=WREG (iej=i+j)
end
.