Successfully reported this slideshow.
Your SlideShare is downloading. ×

Write a code segment in assembly of PIC18 that implement the following.docx

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 2 Ad

Write a code segment in assembly of PIC18 that implement the following.docx

Download to read offline

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
.

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
.

Advertisement
Advertisement

More Related Content

More from lez31palka (20)

Advertisement

Write a code segment in assembly of PIC18 that implement the following.docx

  1. 1. 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

×