diff options
feat: Started working on a catalan numbers program
1 files changed, 32 insertions, 0 deletions
| -rw-r--r-- | catalan/basic_starter.a65 | 32 |
diff --git a/catalan/basic_starter.a65 b/catalan/basic_starter.a65 new file mode 100644 index 0000000..5242418 --- /dev/null +++ b/catalan/basic_starter.a65 @@ -0,0 +1,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 main_addr_ch1 "0" + main / 10000 +#define main_addr_ch2 "0" + (main - main / 10000 * 10000) / 1000 +#define main_addr_ch3 "0" + (main - main / 1000 * 1000) / 100 +#define main_addr_ch4 "0" + (main - main / 100 * 100) / 10 +#define main_addr_ch5 "0" + main - main / 10 * 10 + +.word $0801 ; Header -- addr 2049 +* = $0801 ; Program Counter + +.( + .word eol + .word 10 + .byt $9e," " + .byt main_addr_ch1,main_addr_ch2,main_addr_ch3,main_addr_ch4,main_addr_ch5,0 +eol .word 0 +.) + +// vim: noet ts=8 sw=0 lcs=tab\:\ \ |
