The task involves BASIC V2, calling assembly from BASIC, calling BASIC ROM routines from assembly, SYS, USR, PEEK, POKE, WAIT, tokenization, variable storage, or BASIC program layout.
SYS calls an ML routine as a command.USR(x) calls an ML routine as a function-like expression.PEEK reads one byte; POKE writes one byte.BASIC:
10 SYS 49152
Assembly routine at $C000 must normally end with:
rts
Before SYS, BASIC can place values in these locations:
| Decimal | Hex | Register |
|---|---|---|
| 780 | $030C |
Accumulator A |
| 781 | $030D |
X register |
| 782 | $030E |
Y register |
| 783 | $030F |
Processor status |
Example:
10 POKE 780,65:REM A = PETSCII "A"
20 SYS 49152
30 PRINT PEEK(780)
USR(x) is best when an ML routine should behave like a function.
Use cases:
Cautions:
USR uses BASIC floating-point accumulator conventions.SYS; use SYS first unless function syntax is needed.| Decimal | Hex | Meaning |
|---|---|---|
| 43-44 | $002B-$002C |
Start of BASIC text |
| 45-46 | $002D-$002E |
End of BASIC text |
| 47-48 | $002F-$0030 |
Start of variables |
| 49-50 | $0031-$0032 |
Start of arrays |
| 51-52 | $0033-$0034 |
End of arrays/start of strings |
| 55-56 | $0037-$0038 |
Top of BASIC memory |
10 POKE 53280,6:REM BORDER $D020
20 POKE 53281,0:REM BACKGROUND $D021
10 POKE 1024,1:REM SCREEN CODE A
20 POKE 55296,2:REM COLOR RED IN LOW NYBBLE
For many C64 BASIC programs, $C000 is outside normal BASIC RAM. Still, document the assumption and avoid loaders that extend into $C000.
When producing BASIC+ML examples:
SYS address.RTS.Powered by TurnKey Linux.