When reading from writing to the indf when register

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a RAM address into a FSR, use To LFSR: LFSR: – LFSR 0, 0x030 LFSR – LFSR 1, 0x040 LFSR 0x040 – LFSR 2, 0x06F LFSR 0x06F ;load FSR0 with 0x30 ;load FSR1 with 0x40 ;load FSR2 with 0x6F 49 Register Indirect Addressing Mode Register • FSRx is associated with a INDFx register FSRx (where x = 0, 1, 2). • When reading from (writing to) the INDF When register, we are reading from (writing to) the RAM file register pointed to by FSR the • Example: LFSR 0, 0x030 LFSR 0x030 ;FSR0 points to RAM address 0x30 movwf INDF0 ;copy the content of WREG into ;copy RAM address 0x30 RAM 50 Auto-increment option for FSR Auto-increment • POSTDECx – movwf POSTDEC0 does what movwf INDF0 did, but movwf in addition, FSR0 will be decremented by 1 after decremented after the execution the • POSTINCx – movwf POSTINC0 increments FSR0 by 1 after the movwf increments after move operation. move • PREINCx – movwf PREINC0 increments FSR0 by 1 before the movwf increments before move operation. move • PLUSWx – movwf PLUSW0 adds an offset to FSR0 that equals movwf to the content of WREG before the move operation. However, the content of FSR0 will not be modified 51 after operation (different from previous three SFRs) SFRs) e.g., Write a program to copy the value 0x55 to location 0x40 to 0x44 location COUNT equ 0x00 COUNT movlw 0x05 movwf COUNT movlw 0x55 LFSR 0, 0x040 Loop: movwf POSTINC0 Loop: POSTINC0 decfsz COUNT, F decfsz bra Loop 52 Example Example • Copy a block of 5 bytes of data from Copy RAM locations starting from 0x30 to RAM locations starting from 0x60 RAM Loop: Loop: COUNT equ 0x00 COUNT movlw 0x05 movlw movwf COUNT movwf LSFR 0, 0x030 0x030 LSFR 1, 0X060 0X060 movff POSTINC0, POSTINC1 movff decfsz COUNT, F decfsz bra Loop bra 53 Example Example Add the data in RAM locations 40-43 Add together and place the result in locations 0x06 and 0x07 0x06 COUNT equ 0x0...
View Full Document

This document was uploaded on 11/07/2013.

Ask a homework question - tutors are online