summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-12-11 11:28:30 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2019-12-11 11:28:30 -0500
commit9526483f93b5950ecfa81a93f30b617bec22dfe1 (patch)
tree34ee0e468f3d9ea239870967df1931cef2206dcf /test
parent3dfde833082fc66cededd0206ae5fc76162867b6 (diff)
We can print to the Screen!!!!
I also added the ASR instruction, for doing arithmetic shifts, and have added a hello world program.
Diffstat (limited to 'test')
-rw-r--r--test/asr.s19
-rw-r--r--test/hello-world.s56
2 files changed, 75 insertions, 0 deletions
diff --git a/test/asr.s b/test/asr.s
new file mode 100644
index 0000000..6377875
--- /dev/null
+++ b/test/asr.s
@@ -0,0 +1,19 @@
+; Testing Signed shifts.
+;
+; Writen by mr b0nk 500 <b0nk@b0nk.xyz>
+
+reset:
+ cps
+
+start:
+ lda.q #$-FFFF
+
+signshft:
+ asr #$1
+ cmp.q #$-1
+ beq start
+ jmp signshft
+
+.org $0
+done
+
diff --git a/test/hello-world.s b/test/hello-world.s
new file mode 100644
index 0000000..fef5a46
--- /dev/null
+++ b/test/hello-world.s
@@ -0,0 +1,56 @@
+; Hello world.
+; Writen in Sux assembly by mr b0nk 500 <b0nk@b0nk.xyz>
+
+; Initialize, and declare variables.
+.org $8000
+string:
+ .byte "Hello, world!\n"
+
+; Get CPU into a known state.
+.org $0
+reset:
+ cps ; Reset the processor status.
+ ldx.w #$FFFF ; Set up the stack pointer.
+ txs ; Reset the stack pointer.
+
+; Start of main program.
+start:
+ ldx.w #$0 ; Reset x.
+ jmp print
+
+line_count:
+ iny ; Increment the line count.
+ cpy #$32
+ beq spin ; Have we printed 50 lines?
+ jmp start ; Keep looping until we have printed 50 lines.
+
+; Printing sub routine.
+print:
+ lda string, x ; Get character at offset x.
+ beq line_count ; Did we find a null terminator?
+ sta $C001 ; Print character.
+ inx ; Increment offset.
+ jmp print ; Keep printing more characters.
+
+; The other threads would clash, if we're running the same code.
+; So, have them spin instead, please?
+.org $1000
+spin:
+ nop
+ nop
+ nop
+ jmp spin
+
+.org $FFC0
+.qword reset
+
+.org $FF50
+.qword spin
+.qword spin
+.qword spin
+.qword spin
+.qword spin
+.qword spin
+.qword spin
+done
+