05 ; #D:RELJMP.LST
0100 ;
0120 ;RELJMP jumps to a label
0140 ;RELJMP orgadr, label, relstart
0160 ;
0180 ;orgadr is the ORG (*=) Label
0200 ;label is the address of the label you want to jump to
0220 ;relstart is the start address of the string that contains the ML code from BASIC
0225 ;relstart is external from the program
0230 ;relstart example - $D4
0240 ;
0260 ;have BASIC put ADR(sting$)
0280 ;store it at $D2 and $D3, $D4 through $FF, $100 and $101
0300 ;don't ust $D4 through $FF if your ML program calls the floating Point Package
0320 ;
0340 ;or get relstart from $D4 and $D5, FR0 - the first floating point register
0360 ;FR0 won't hold the runtime start address after your ML program accesses the floating point package
0380 ;
0400 ;this routine uses the A and X registers
0420 ;
0440 ;RELJMP orgadr, label, relstart
0460 ;
0480 .MACRO RELJMP
0500 CLC
0520 LDA # <[%2-%1]-1 ;calculate low byte
0540 ADC %3
0560 TAX ;put it in the X register
0580 ;----------------------
0600 LDA # >[%2-%1]-1 ;high byte
0620 ADC %3+1
0640 PHA ;push high byte
0660 ;----------------------
0680 TXA ;get low byte from the X register
0700 PHA ;push low byte
0720 ;
0740 RTS ;jump to label
0760 ;
0780 .ENDM
0800 ;
Back