summaryrefslogtreecommitdiff
path: root/test/fib.s
blob: 0d3ee03f866172187d21ad2aed56afd3f10ee106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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