fsr across memory banks
Javalin
Posts: 892
Hi,
Im trying to use the FSR for indirect addressing across banks.· I believe the the FSR is in bank0 so should be accessible from where-ever.
When I debug the code the data is stored in the wrong locations in the banks.· If I try to put bank 2, or bank bank2 instructions in the code the compiler throws up "pass 2:· variable not in current bank" type messages.
What am I missing?
My code (snippits) is below:
org··$50····;bank 2 address on SX28
bank2··=·$
FIFO1Head· ····ds 1··················· ; FIFO head pointer
FIFO1Tail· ····ds 1··················· ; FIFO tail pointer
Temp1W··· ····ds 1··················· ; Temporary storage
Temp1R··· ····ds 1··················· ; Temporary storage
FIFO1Cnt ····ds 1··················· ; Current number of items the FIFO
org··$70····;bank 3 address on SX28
bank3··=·$
FIFO1·· ·= $················ ; 16 bytes for FIFO memory
·······ds 16····; this is for SERIAL1
then called from·the main program bank·:-
org·$200
;*********************************************************************************
; Function: ReadFIFO1
ReadFIFO1
·bank ·bank2
·test ·FIFO1Cnt··············· ; If FIFOCnt = 0, the
·snz·························· ·;· FIFO is "empty",
·· ·retp··················· ··;· no action
·mov· ·FsrSave, fsr·········· ; Save the FSR
·mov· ·w, #FIFO1·············· ; Indirectly address the FIFO-Puffer
·add· ·w, FIFO1Tail··············· ;· using the Head pointer
·mov· ·fsr, w················· ;
·mov· ·Temp1R, ind············ ; Read the value from the FIFO
·inc· ·FIFO1Tail·················· ; Set Tail to next location
·clrb ·FIFO1Tail.4················ ; If Tail = 16, "circle" around to 0
·dec· ·FIFO1Cnt··············· ; Decrement the item count
·mov· ·fsr, FsrSave··········· ; Restore the FSR
·mov· ·w, Temp1R·············· ; Copy the value to w
retp
Thanks
James
Im trying to use the FSR for indirect addressing across banks.· I believe the the FSR is in bank0 so should be accessible from where-ever.
When I debug the code the data is stored in the wrong locations in the banks.· If I try to put bank 2, or bank bank2 instructions in the code the compiler throws up "pass 2:· variable not in current bank" type messages.
What am I missing?
My code (snippits) is below:
org··$50····;bank 2 address on SX28
bank2··=·$
FIFO1Head· ····ds 1··················· ; FIFO head pointer
FIFO1Tail· ····ds 1··················· ; FIFO tail pointer
Temp1W··· ····ds 1··················· ; Temporary storage
Temp1R··· ····ds 1··················· ; Temporary storage
FIFO1Cnt ····ds 1··················· ; Current number of items the FIFO
org··$70····;bank 3 address on SX28
bank3··=·$
FIFO1·· ·= $················ ; 16 bytes for FIFO memory
·······ds 16····; this is for SERIAL1
then called from·the main program bank·:-
org·$200
;*********************************************************************************
; Function: ReadFIFO1
ReadFIFO1
·bank ·bank2
·test ·FIFO1Cnt··············· ; If FIFOCnt = 0, the
·snz·························· ·;· FIFO is "empty",
·· ·retp··················· ··;· no action
·mov· ·FsrSave, fsr·········· ; Save the FSR
·mov· ·w, #FIFO1·············· ; Indirectly address the FIFO-Puffer
·add· ·w, FIFO1Tail··············· ;· using the Head pointer
·mov· ·fsr, w················· ;
·mov· ·Temp1R, ind············ ; Read the value from the FIFO
·inc· ·FIFO1Tail·················· ; Set Tail to next location
·clrb ·FIFO1Tail.4················ ; If Tail = 16, "circle" around to 0
·dec· ·FIFO1Cnt··············· ; Decrement the item count
·mov· ·fsr, FsrSave··········· ; Restore the FSR
·mov· ·w, Temp1R·············· ; Copy the value to w
retp
Thanks
James
Comments
mov fsr,w
mov Temp1R,ind ; This won't work because fsr is pointing to bank 3
you need to store ind in w then set fsr back to bank2 then copy from w to Temp1R.
remember BANK just sets FSR to the value, they are changing the same variable (FSR).
Try using w for temporary storage.
mov fsr,w
mov w,ind
bank bank2 ; DON'T DO "mov fsr,FsrSave" here·because it will destroy w
mov Temp1R,w
mov fsr,FsrSave ; I assume FsrSave is in the global area
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out· the "SX-Video Display Module"
www.sxvm.com
Post Edited (Bean) : 3/16/2005 7:42:29 PM GMT
You may want to consider using the hidden FIFO in the SX since you get a 16 byte FIFO without using any of your memory banks.
Post Edited (Paul Baker) : 3/17/2005 3:33:11 AM GMT
Thanks for the answers.
James
Where did the 16 byte FIFO come from????
The "hidden" FIFO is only 8 bytes.......
Peter