diff options
| Commit | b54b80ec4c071b5464e631daadcbd240f4723a7f (patch) | |
|---|---|---|
| Author | 2025-08-01 16:52:19 +0300 | |
| Committer | 2025-08-01 16:52:19 +0300 | |
| Files | dcdbe18dc48123a8894705eae1f634ddec143fc2 | |
| c64-programs-b54b80ec4c071b5464e631daadcbd240f4723a7f.tar c64-programs-b54b80ec4c071b5464e631daadcbd240f4723a7f.tar.gz c64-programs-b54b80ec4c071b5464e631daadcbd240f4723a7f.zip | ||
| Parent | 7136a8d938c38535d13a8ff5b5aee3ad2c8be512 (diff) | |
feat: Started working on a catalan numbers program
4 files changed, 71 insertions, 0 deletions
| -rw-r--r-- | catalan/Makefile | 17 | ||||
| -rw-r--r-- | catalan/basic_starter.a65 | 32 | ||||
| -rw-r--r-- | catalan/catalan.a65 | 9 | ||||
| -rw-r--r-- | catalan/kernal.a65 | 13 |
diff --git a/catalan/Makefile b/catalan/Makefile new file mode 100644 index 0000000..596e512 --- /dev/null +++ b/catalan/Makefile @@ -0,0 +1,17 @@ +AS=xa +FILES=catalan.a65 +VICE=x64 +VICEFLAGS=-VICIIfilter 0 +confirmonexit + +.PHONY: build execute run + +build: + $(AS) $(FILES) -o catalan.prg + +dump: + $(AS) $(FILES) -P - -o /dev/null + +execute: + $(VICE) $(VICEFLAGS) *.prg >/dev/null + +run: build execute 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\:\ \ diff --git a/catalan/catalan.a65 b/catalan/catalan.a65 new file mode 100644 index 0000000..5b544a2 --- /dev/null +++ b/catalan/catalan.a65 @@ -0,0 +1,9 @@ +#include "basic_starter.a65" +#include "kernal.a65" + +hello .byt "HELLO, WORLD!",0 + +main print(hello) + rts + +// vim: noet ts=8 sw=0 lcs=tab\:\ \ diff --git a/catalan/kernal.a65 b/catalan/kernal.a65 new file mode 100644 index 0000000..40db36f --- /dev/null +++ b/catalan/kernal.a65 @@ -0,0 +1,13 @@ +#define putchar() jsr $FFD2 + +#define print(str) .( :\ + ldx #0 ; x = 0 :\ +loop lda str, x ; while (_1[x] != 0) :\ + beq end :\ + putchar() ; putchar(_1[x]) :\ + inx ; ++x :\ + bne loop ; if (x == 0) break :\ +end :\ +.) + +// vim: noet ts=8 sw=0 lcs=tab\:\ \ |
