Chapter 3C PIC18 Assembly Programming Part C
Chapter 3C PIC18 Assembly Programming Part C
Outline
;[WREG] = 0
movwf
0x20, A
;[0x20] = 0, [WREG] = 0
incf
0x20, W, A
;[0x20] = 0, [WREG] = 1
incf
0x20, W, A
;[0x20] = 0, [WREG] = 1
incf
0x20, F, A
;[0x20] = 1, [WREG] = 1
incf
0x20, F, A
;[0x20] = 2, [WREG] = 1
0x55
0x40,
0x41,
0x42,
0x43,
0x44,
A
A
A
A
A
6
LFSR 0, 0x030
LFSR 1, 0x040
LFSR 2, 0x06F
movwf INDF0
Examples
e.g., Write a program to copy the value 0x55 to location
0x40
0x44
Directto
Addressing
Mode
Indirect Addressing Mode
movlw
movwf
movwf
movwf
movwf
movwf
0x55
0x40,
0x41,
0x42,
0x43,
0x44,
A
A
A
A
A
10
POSTINCx
PREINCx
PLUSWx
Demonstration
13
14
Example
Copy a block of 5 bytes of data from
RAM locations starting from 0x030 to
RAM locations starting from 0x060
Loop:
15
Example
Add the in data memory locations 0x040-043
together and place the result in locations 0x006
and 0x007
COUNT equ 0x00
L_BYTE equ 0x06
H_BYTE equ 0x07
LFSR 0, 0X040
movlw 0x04
movwf COUNT, A
clrf H_BYTE, A
clrf L_BYTE, A
Loop:
movf POSTINC0, W, A;
addwf L_BYTE, F, A;
bnc Next
incf H_BYTE, F, A;
Next:
decfsz COUNT, F, A
bra Loop
16