Page 7 of 62
SBasic User's Manual SBasic Version 2.7 Page 7
Printed: December 5, 1999
contains a branch instruction that tests the value of variable N and
branches back to the WHILE statement if N equals 3.
For the 68hc11 and 68hc12 MCUs, SBasic normally generates code similar
to:
whl000
ldd var001
cpd #3
bne *+5 branch instruction, line 1
jmp whl000 branch instruction, line 2
For short transfers, where the branch target is within the relative
addressing limit of the target MCU, this code is larger and will run
more slowly than necessary.
Using the /b option forces SBasic to generate relative branches
directly to all targets. If the /b option is in effect, SBasic would
generate the following code for the above example:
whl000
ldd var001
cpd #3
beq whl000 branch instruction
Note that the branch has reversed sense, and the JMP instruction has
disappeared.
WARNING: Branches to addresses beyond the target MCU's
relative branch limit will result in assembler errors, even
though SBasic will not report any compilation errors.
SBasic does not maintain an internal program counter, and
will not detect that a branch target is out of range.
Beginning users should omit the /b option, and accept the slight
increase in size and execution times caused by the default branch code
generation.
Experienced users may, however, use the /b option to gain improved
performance. In this case, however, you must carefully monitor the
assembler's output for any errors resulting in out-of-range branches.
If your code generates out-of-range branches using the /b option,
recompile without the option. SBasic currently does not support any
method for selectively compiling direct branches.
You can select the target MCU by using the /m option. The format of
this option is:
/mxxxx