1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/* PRG format
* Contains two bytes of header data, address from which
* the rest of the file will be loaded into memory.
* BASIC memory starts at addr 2048, we effectively place "10 SYS 2064"
* and an end of program after it. Then immedately afterwards
* we place our command on addr 2064.
* When BASIC loads up, it runs "10 SYS 2064" and passes up execution there.
* Then, when we return, we get a zero which indicates termination.
*/
/* The starting address is defined by the value (label or alias) "main".
* Since in basic we need to provide a decimal string, but we store a decimal value, we need
* to do this complicated convertion.
*/
#define addr_to_ch(addr) \
"0" + addr / 10000, \
"0" + (addr - addr / 10000 * 10000) / 1000, \
"0" + (addr - addr / 1000 * 1000) / 100, \
"0" + (addr - addr / 100 * 100) / 10, \
"0" + addr - addr / 10 * 10
.word $0801 ; Header -- addr 2049
* = $0801 ; Program Counter
.(
.word eol
.word 10
.byt $9e," ",addr_to_ch(main),0
eol .word 0
.)
// vim: noet ts=8 sw=0 lcs=tab\:\ \
|