for what it worth you might save a nano second or two
i'm not exactly sure how the assembler works but SFR's that are in the access bank can be referenced without needing to select bank 15 explicitly, not all SFR's are in access bank
notice that addwf FSR0L, f works ok with out a banksel 15.
Technically movwf LATC,f,a would be more correct but the ass seems to interpret movwf LATC correctly no matter what bank is selected
Code:
MOTOR_CONTROL:ASM
banksel _mcount ; Variables used in interrupts are stored one bank via config definition - can change bank # as long as vars are in same bank
movf _mcount, W ; Get index value from variable 'mcount' for array address, store in WREG
incf _mcount, f ; Increment mcount before changing banks
lfsr FSR0, _motor ; Load the full 12-bit address of motor array into FSR0
addwf FSR0L, f ; Add offset to low byte of pointer
movlw 0 ; clear WREG although carry flag is still active in STATUS REGISTER bit0
addwfc FSR0H, f ; Add carry to high byte of pointer
movf INDF0, W ; Move INDF0 to WREG
;banksel LATC not needed LATC is in access bank ; Change bank to LATC
movwf LATC ; Change PORTC outputs based on WREG
banksel _mcount
movf _mcount, W ; Get index value from variable 'mcount' for array address, store in WREG
lfsr FSR0, _preload ; Load the full 12-bit address of preload array into FSR0
addwf FSR0L, f ; Add offset to low byte of pointer
movlw 0 ; clear WREG although carry flag is still active in STATUS REGISTER bit0
addwfc FSR0H, f ; Add carry to high byte of pointer
movf INDF0, W ; Move INDF0 to WREG
;banksel TMR1H not needed TMR1H is in access bank ; Change bank to TMR1H
movwf TMR1H ; Load preload byte into TMR1H
INT_RETURN
endasm
Bookmarks