??? 10/20/06 16:35 Read: times |
#126810 - bank switching mechanism (RFC) Responding to: ???'s previous message |
if you look at the code needed for bank switching then the 64k barrier is really a barrier.
Two quite different implementations: for SDCC: http://svn.sourceforge.net/viewvc/sd...iew=markup for Keil: L51_BANK.A51 usually bank switching code has to setup stuff first, then call a routine in common memory, switch, then call the code, then return to the common memory, switch again, then return to the caller. (You'll of course be familiar with this) Now if you do a new design you could avoid the need for the jump into the common memory altogether (and would have an overhead of only one instruction over non banked calls:) You'd need a (separate) return stack holding the calling bank though. in an arbitrary bank: mov SFR_BANK_TO_SELECT_ON_NEXT_LCALL, #0x03; pushes target bank ; on top of seperate stack ; lock IRQ for 1 instruction? ; (as if IRQ enable is touched?) ; lcall my_func_in_bank3 ; pushing address on stack and ; current bank on a separate ; (32/64 byte deep) stack then in bank3: my_func_in_bank3: ... ret ; returns to address defined by ; the two topmost entries of the ; normal stack and the bank stored on ; the topmost entry of the ; separate stack reading SFR_BANK_TO_SELECT_ON_NEXT_LCALL could give the calling bank and remove the topmost entry. There must be a caveat somewhere, comments? Greetings, Frieder |