display | more...

Beginners who code in Commodore 64 assembler often place their program to area $C000 and onward. The magical SYS 49152.

Of course, it's much neater to place the programs to BASIC RAM! You can fit many many many kilobytes to that space, and programs can be started with just RUN command!

The creation of such BASIC stub is simple if you're using some sort of cross-compiler. Basically, write something like this in BASIC:

10 sys 2200
20 rem (c) Your Name
30 rem Whatever Comments You Want To Put Here

And then save "stub",8,1 to store that to the floppy.

Basically, you want to edit the program to make the SYS to jump to the byte just beyond the end of this BASIC program. It helps if you use an emulator or a turbo module that says which bytes the program is on when you load it. (BASIC programs start from address 2049, putting it just a bit above that may help.)

You probably want then to turn the program into hex form that your assembler likes...

Here's my own BASIC stub, in format the assembler recognizes:

        .byt $0d, $08, $0a, $00, $9e,
        .asc "2108"             ; Start address! Be *very* careful!
        .byt $00, $27, $08, $14, $00, $8f,
        .asc " (C) WEYFOUR WWWWOLF", 0
        .byt $3c, $08, $1e, $00, $8f,
        .asc " WWWWOLF@IKI.FI",0,0,0

And here's how to use this in the program:

     .word $0801       ; File header
*=$0801                ; Start address
#include <basicstub.s> ; BASIC stub
MAIN:        ...       ; The assembly program

Note that this is how it works in cross-assemblers. You may need to manually set the end of BASIC memory area if you're not that crafty.

I'm not good at knowing what the tokens really mean but I guess the 0,0,0 in the end is some end signal for the BASIC interpreter to stop the program or end the listing...

Log in or register to write something here or to contact authors.