Summary Files Commits Branches @commit @diff @stats
path: root / catalan / basic_starter.a65
diff options
context:
space:
mode:
Commitb54b80ec4c071b5464e631daadcbd240f4723a7f (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-08-01 16:52:19 +0300
Committer
 Syndamia <kamen@syndamia.com>
2025-08-01 16:52:19 +0300
Filesdcdbe18dc48123a8894705eae1f634ddec143fc2 /catalan/basic_starter.a65
c64-programs-b54b80ec4c071b5464e631daadcbd240f4723a7f.tar
c64-programs-b54b80ec4c071b5464e631daadcbd240f4723a7f.tar.gz
c64-programs-b54b80ec4c071b5464e631daadcbd240f4723a7f.zip
Parent7136a8d938c38535d13a8ff5b5aee3ad2c8be512 (diff)
feat: Started working on a catalan numbers program
1 files changed, 32 insertions, 0 deletions
-rw-r--r--catalan/basic_starter.a6532
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\:\ \