summaryrefslogtreecommitdiff
path: root/test/fib-new.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-02-20 18:18:50 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-02-20 18:18:50 -0500
commit34b9bda535d475dd80fd70481fb7ba525b8c58bd (patch)
tree432202e64d1c943f46c0b2fee7402586e06d969b /test/fib-new.s
parent63d5046ecabd5fd1524d3c4bc4590176c3b8a4eb (diff)
Finished SuBAsm's screen editor.
Which I am now calling, SuBEditor.
Diffstat (limited to 'test/fib-new.s')
-rw-r--r--test/fib-new.s73
1 files changed, 73 insertions, 0 deletions
diff --git a/test/fib-new.s b/test/fib-new.s
new file mode 100644
index 0000000..43538a0
--- /dev/null
+++ b/test/fib-new.s
@@ -0,0 +1,73 @@
+; Name: fib.s
+; Description: Computes the Fibbonacci sequence.
+;
+; Written in Sux Assembly
+; by mr b0nk 500 <b0nk@b0nk.xyz>
+
+; Variables for thread 0.
+.org $0
+x:
+ .qword $0
+y:
+ .qword $0
+z:
+ .qword $0
+
+; Variables for thread 1.
+x2:
+ .qword $0
+y2:
+ .qword $0
+z2:
+ .qword $0
+
+.org $1000
+init:
+ cps ; Clear the Processor Status register.
+
+start:
+ lda #$0 ; Clear the accumulator.
+ ldy #$1 ; y=1.
+ sty.q y ; Store y into memory.
+
+fib:
+ ldx #$0 ; x=0.
+ ldx.q x ; Output the value of x.
+ adc.q y ; Add x with y.
+ sta.q z ; z=x+y
+ ldy.q y
+ sty.q x ; x=y.
+ sta.q y ; y=z.
+ lda.q x
+ bcs start ; Start all over again, if the carry flag was set.
+ jmp fib ; Otherwise, keep looping.
+
+.org $2000
+init2:
+ cps ; Clear the Processor Status register.
+
+start2:
+ lda #$0 ; Clear the accumulator.
+ ldy #$1 ; y2=1.
+ sty.q y2 ; Store y into memory.
+
+fib2:
+ ldx #$0 ; x2=0.
+ ldx.q x2 ; Output the value of x2.
+ adc.q y2 ; Add x2 with y2.
+ sta.q z2 ; z2=x2+y2
+ ldy.q y2
+ sty.q x2 ; x2=y2.
+ sta.q y2 ; y2=z2.
+ lda.q x2
+ bcs start2 ; Start all over again, if the carry flag was set.
+ jmp fib2 ; Otherwise, keep looping.
+
+.org $FFC0
+.qword init
+; Set up the thread vectors.
+.org $FF50
+.qword init2
+; Execute the program.
+done
+