User Tools

Site Tools


base:runasmfrombasic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
base:runasmfrombasic [2017-07-28 12:44] – Using 57/58 from zeropage pararaumbase:runasmfrombasic [2017-07-28 12:53] (current) – Fixed typo. pararaum
Line 49: Line 49:
  
 ==== Fancier ways to call the Assembler code ==== ==== Fancier ways to call the Assembler code ====
 +
 +=== Using the current line number ===
  
 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: 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:
Line 69: Line 71:
  
 This code uses the zeropage locations $39/$3A which contain the current line number in the basic program, see [[https://www.c64-wiki.com/wiki/zeropage|zeropage description]]. The line number was selected to be the entry of the main routine. This code uses the zeropage locations $39/$3A which contain the current line number in the basic program, see [[https://www.c64-wiki.com/wiki/zeropage|zeropage description]]. The line number was selected to be the entry of the main routine.
 +
 +=== Using ASC() ===
 +
 +If you like to get your code fancier you can use something like this:
 +
 +  .word $0801
 +  * = $0801
 + 
 +  basic: .(
 +  .word L1
 +  .word main
 +  .byte $9e
 +  .asc "(",$c6,"(",$22
 +  .byte ((main>>6)&$3f)+$20
 +  .asc $22,")",$ab,"32)",$ac,"64",$aa,$c6,"(",$22
 +  .byte ((main)&$3f)+$20
 +  .asc $22,")",$ab,"32"
 +  .asc 0
 +  L1: .word end_of_basic
 +  .word L1
 +  .byte $8f,$20
 +  .asc "ANOTHER VISITOR STAY A WHILE...",0
 +  end_of_basic:
 +  .word 0,0
 +  .)
 +  
 +  main: lda #$0d
 +  sta $d020
 +        rts
 +
 +This use two characters to encode the starting address (maximum is 4096). The basic code actually reads:
 +
 +  2121 SYS(ASC("A")-32)*64+ASC(")")-32
 +  2079 REM ANOTHER VISITOR STAY A WHILE...
 +
 +The line numbers are even not ordered but this code safely runs.
base/runasmfrombasic.1501238653.txt.gz · Last modified: 2017-07-28 12:44 by pararaum