Friday, February 28, 2014

Assembly Language Incrementation code using FSR0 and INDF0

This was a homework code written for my microprocessors class a few days ago.  I thought I should  post something today since I'm going to be passing out business cards at the Society of Women Engineets conference today and tomorrow so if that's what brought you to my blog, then I'm glad you were curious enough to stop by!  Feel free to contact me via email or phone with any questions. My phone number is on my card as well. 
;--------------------------
;FILE: main.asm
;DESC HW8
;Date: 3-3-2014
;Device: PIC18F1220
;--------------------------

​list p=18F1220
​radix hex
​config WDT=OFF, LVP=OFF

#include P18F1220.INC

NUM EQU 0x21​​​;put NUM somewhere out of the way

​MOVLW 0x01​
​MOVWF NUM​​​;initialize NUM to 1
​MOVFF NUM, INDF0​​;initialize INDF0 to 1
​MOVLW 0X00
​MOVWF FSR0L​​​;initialize FRS0 to 0

loop:​​​​​;where incrementation will take place
​MOVLW d'2'​
​ADDWF NUM​​​;add decimal 2 to $NUM
​
​MOVLW 0x01
​ADDWF FSR0L​​​;increment FSR0 (0 to 15), also increments location of INDF0 from 0 to 15

​MOVFF NUM, INDF0​;move contents of NUM into INDF0

​MOVLW 0x0F
​SUBWF FSR0L,W​​;subtract 15 from FSR0L, store in WREG
​BNZ loop​​​;if FSR0 != 15, go back and loop again. Else proceed to endloop

endloop:
​BRA endloop​​​;Bask in glory of filling first 16 locations (0-15)

          end 

No comments:

Post a Comment