summaryrefslogtreecommitdiff
path: root/test/fib.s
diff options
context:
space:
mode:
Diffstat (limited to 'test/fib.s')
-rw-r--r--test/fib.s45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/fib.s b/test/fib.s
new file mode 100644
index 0000000..0d3ee03
--- /dev/null
+++ b/test/fib.s
@@ -0,0 +1,45 @@
+; Name: fib.s
+; Description: Computes the Fibbonacci sequence.
+;
+; Written in Sux Assembly
+; by mr b0nk 500 <b0nk@b0nk.xyz>
+
+
+cps ; Clear the Processor Status register.
+lda #$0 ; Clear the accumulator.
+ldy #$1 ; y=1.
+sty.q $1008 ; Store y into memory.
+ldx #$0 ; x=0.
+ldx.q $1000 ; Output the value of x.
+adc.q $1008 ; Add x with y.
+sta.q $1010 ; z=x+y
+ldy.q $1008
+sty.q $1000 ; x=y.
+sta.q $1008 ; y=z.
+lda.q $1000
+bcs $1 ; Start all over again, if the carry flag was set.
+jmp $D ; Otherwise, keep looping.
+
+.org $8000
+
+cps ; Clear the Processor Status register.
+lda #$0 ; Clear the accumulator.
+ldy #$1 ; y=1.
+sty.q $2008 ; Store y into memory.
+ldx #$0 ; x=0.
+ldx.q $2000 ; Output the value of x.
+adc.q $2008 ; Add x with y.
+sta.q $2010 ; z=x+y
+ldy.q $2008
+sty.q $2000 ; x=y.
+sta.q $2008 ; y=z.
+lda.q $2000
+bcs $8001 ; Start all over again, if the carry flag was set.
+jmp $800D ; Otherwise, keep looping.
+
+; Set up the thread vectors.
+.org $FF50
+.qword $8000
+; Execute the program.
+done
+