base:runasmfrombasic
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
base:runasmfrombasic [2017-07-28 12:16] – created pararaum | base:runasmfrombasic [2017-07-28 12:44] – Using 57/58 from zeropage pararaum | ||
---|---|---|---|
Line 13: | Line 13: | ||
At $0801 is the pointer to the next Basic line the following two byte are the little endian number $07c0 which is the line number 1984 the follows $9e which is the Basic token for SYS. After that we have a space and the number 2084 in PETSCII. | At $0801 is the pointer to the next Basic line the following two byte are the little endian number $07c0 which is the line number 1984 the follows $9e which is the Basic token for SYS. After that we have a space and the number 2084 in PETSCII. | ||
+ | ==== A simple stub for use ==== | ||
+ | |||
+ | A simple stub program looks like this (this uses xa65 syntax, see [[http:// | ||
+ | |||
+ | .word $0801 | ||
+ | * = $0801 | ||
+ | |||
+ | basic: .( | ||
+ | .word end_of_basic | ||
+ | .word 2017 | ||
+ | .byte $9e,$20 | ||
+ | .asc " | ||
+ | end_of_basic: | ||
+ | .byte 0,0,0 | ||
+ | .) | ||
+ | | ||
+ | main: sta $0400 | ||
+ | stx $0401 | ||
+ | sty $0402 | ||
+ | php | ||
+ | pla | ||
+ | sta $0403 | ||
+ | lda #$ff | ||
+ | tax | ||
+ | tay | ||
+ | rts | ||
+ | |||
+ | compiles to: | ||
+ | |||
+ | > | ||
+ | > | ||
+ | > | ||
+ | |||
+ | As can be easily seen the SYS to address 2064 starts the code at $0810. | ||
+ | |||
+ | ==== Fancier ways to call the Assembler code ==== | ||
+ | |||
+ | This is the canonical way to call an Assembler code. Usually you precalculate the entry or you have to be very careful when changing the basic stub. Another nice way to call the assembler code is the following stub: | ||
+ | |||
+ | .word $0801 | ||
+ | * = $0801 | ||
+ | |||
+ | basic: .( | ||
+ | .word end_of_basic | ||
+ | .word main | ||
+ | .byte $9e,$20,$c2 | ||
+ | .asc " | ||
+ | end_of_basic: | ||
+ | .byte 0,0,0 | ||
+ | .) | ||
+ | | ||
+ | main: lda #$0d | ||
+ | sta $d020 | ||
+ | rts | ||
+ | |||
+ | This code uses the zeropage locations $39/$3A which contain the current line number in the basic program, see [[https:// |
base/runasmfrombasic.txt · Last modified: 2017-07-28 12:53 by pararaum