Page 49 of 62
SBasic User's Manual SBasic Version 2.7 Page 49
Printed: December 5, 1999
force the vectors to appear at the proper locations, and also to force
the library routines to compile in the correct locations, I had to use
the third variation of the ORG statement above.
For example, I compiled the following portions of code using a /c
option of $f700:
org $8000 code ' redefine code section here
main:
n = 14 ' this is the mainline code
... ' rest of mainline code goes here
org $f7e8 ' address of RTI vector
asm ' switch to assembly language
jmp _rtiisr use an assembly JMP instruction
endasm ' back to SBasic
org code ' return to code section
end ' end of program
The /cf700 option started compilation with the code section at $f700.
This caused SBasic to write the startup library code at $f700. The
ORG $8000 statement then moved MAIN down to $8000 and also caused the
code section to move to that address. The rest of the mainline code
(not shown here) compiled from there.
Next, the ORG $f7e8 let me write a JMP instruction into the
bootloader's vector area for use by the RTI interrupt. Finally, the
ORG CODE statement switched back to the code section, now somewhere
above $8000.
This last step is important. SBasic automatically switches to the
code section before adding any library files at the end of the
compilation. If I hadn't moved the code section to $8000, SBasic
would have added the library files at $f700, which was the original
code section. The resulting executable file would have failed.