Truncated match.
PICList
Thread
'Bank switching behavior'
1994\07\26@113450
by
greg
|
I'm using Parallax's assembler to target a 16C57. I noticed an
interesting behavior: When I use LCALL instruction to jump to a
sub-routine in another bank, subsequent jump instructions (JNZ, etc)
in the main code don't work correctly.
This is because the LCALL sets the bank select bits. When the RET
instruction is executed, these don't get reset back to the bank of the
LCALL. So any 9-bit jumps go to the bank where the subroutine was
located! This is easily fixed by using LSET just before the RET to set
the bank select bits back to the calling bank (which means you can only
call that subroutine from one bank).
Example:
org 00h ; bank 0
lcall other_sub ; call subroutine in bank 1
mov w, some_variable ; do something afterwards
xor w, #012h
jnz :not_twelve ; this jump will not work correctly! Bank select
... ; bits are set to 01.
..
:not_twelve ; this line will not be reached
... ; instead, jnz will jump to somewhere in bank 1
..
org 200h ; bank 1
other_sub ; bank select bits are 01 at this point
...
..
RET ; bank select bits do not change with this ret.
-------
Anyone have insight on this problem? The LSET workaround is OK, but I'm
wondering if I'm missing something.
--
Greg Bell | "Ever see a company's sales drop sharply due to an
spam_OUTgregTakeThisOuT
cqt.com | annoying ad campaign? You will."
-----------------------------------------------------------------------
CommQuest Technologies, Inc. (619) 633-1618 x133
More... (looser matching)
- Last day of these posts
- In 1994
, 1995 only
- Today
- New search...