; Name: fib.s ; Description: Computes the Fibbonacci sequence. ; ; Written in Sux Assembly ; by mr b0nk 500 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