diff options
| Commit | c1f0d07847f3652f1f4e63015f928b9a1c1bb825 (patch) | |
|---|---|---|
| Author | 2025-07-31 09:44:21 +0300 | |
| Committer | 2025-07-31 09:44:21 +0300 | |
| Files | a947f8ab0e5025edc6d91dd6f0d18afd717d3d9c | |
| c64-programs-c1f0d07847f3652f1f4e63015f928b9a1c1bb825.tar c64-programs-c1f0d07847f3652f1f4e63015f928b9a1c1bb825.tar.gz c64-programs-c1f0d07847f3652f1f4e63015f928b9a1c1bb825.zip | ||
| Parent | 28c8c0d08f6d0aa61e49627c8b920c7dfee83dca (diff) | |
feat(isprime): Implemented simple conditional
4 files changed, 77 insertions, 0 deletions
| -rw-r--r-- | isprime/Makefile | 17 | ||||
| -rw-r--r-- | isprime/basic_starter.oph.s | 19 | ||||
| -rw-r--r-- | isprime/isprime.oph.s | 24 | ||||
| -rw-r--r-- | isprime/kernal.oph.s | 17 |
diff --git a/isprime/Makefile b/isprime/Makefile new file mode 100644 index 0000000..d2c57b3 --- /dev/null +++ b/isprime/Makefile @@ -0,0 +1,17 @@ +AS=ophis +FILES=isprime.oph.s +VICE=x64 +VICEFLAGS=-VICIIfilter 0 +confirmonexit + +.PHONY: build execute run + +build: + $(AS) $(FILES) + +dump: + $(AS) $(FILES) -l - + +execute: + $(VICE) $(VICEFLAGS) *.prg >/dev/null + +run: build execute diff --git a/isprime/basic_starter.oph.s b/isprime/basic_starter.oph.s new file mode 100644 index 0000000..cf7c410 --- /dev/null +++ b/isprime/basic_starter.oph.s @@ -0,0 +1,19 @@ +; 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. +.alias main_addr_ch1 '0 + main / 10000 ; 65535 -> 6 +.alias main_addr_ch2 '0 + [main - main / 10000 * 10000] / 1000 ; 65535 -> 65535 - 60000 = 5535 / 1000 = 5 +.alias main_addr_ch3 '0 + [main - main / 1000 * 1000] / 100 ; 65535 -> 65535 - 65000 = 535 / 100 = 5 +.alias main_addr_ch4 '0 + [main - main / 100 * 100] / 10 ; 65535 -> 65535 - 65500 = 35 / 10 = 3 +.alias main_addr_ch5 '0 + main - main / 10 * 10 ; 65535 -> 65535 - 65530 = 5 + +.word $0801 ; Header -- addr 2049 +.org $0801 ; Program Counter + +.scope + .word _eop ; Next line addr (I guess it is used to tell how long the line is?) + .word 10 ; 10 (line of BASIC program) + .byte $9e," " ; SYS 2064 (opcode for SYS and null terminated string) + .byte main_addr_ch1,main_addr_ch2,main_addr_ch3,main_addr_ch4,main_addr_ch5,0 +_eop: .word 0 ; End of program +.scend diff --git a/isprime/isprime.oph.s b/isprime/isprime.oph.s new file mode 100644 index 0000000..9fbc15e --- /dev/null +++ b/isprime/isprime.oph.s @@ -0,0 +1,24 @@ +; .org is ONLY used for internal (assembler/label/alias/...) values, it doesn't output anything! +; So you cannot use .org to place data on a given location. + +.outfile "isprime.prg" + +.require "basic_starter.oph.s" +.require "kernal.oph.s" + +number: .word 1 + +main: + `lowercase + lda number + bne + ; if (a == 0) + `print yes + rts +* `print no + rts + +.charmap 'A, "abcdefghijklmnopqrstuvwxyz" +.charmap 'a, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + +yes: .byte "Yes",0 +no: .byte "No",0 diff --git a/isprime/kernal.oph.s b/isprime/kernal.oph.s new file mode 100644 index 0000000..a9fd007 --- /dev/null +++ b/isprime/kernal.oph.s @@ -0,0 +1,17 @@ +.alias putchar $FFD2 + +; print [null-terminated string start address] +.macro print + ldx #0 ; x = 0 + _loop: lda _1, x ; while (_1[x] != 0) { + beq _done + jsr putchar ; putchar(_1[x]) + inx ; ++x + bne _loop ; if (x == 0) break } This allows max 255 character to be read + _done: +.macend + +.macro lowercase + ldx #23 + stx 53272 +.macend |
