From 1e3787256c8fb98c41e3263fe697f30557a895fe Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 7 Dec 2019 18:21:05 -0500 Subject: Added support for labels to the assembly language monitor. I also rewrote the fibonacci program to include lables. --- test/fib.s | 75 ++++++++++++++++++++++++++++++++++----------------- test/test-stack.s | 5 +++- test/test-the-tests.s | 42 ++++++++++++++++++++++------- 3 files changed, 87 insertions(+), 35 deletions(-) (limited to 'test') diff --git a/test/fib.s b/test/fib.s index 0d3ee03..9188a3c 100644 --- a/test/fib.s +++ b/test/fib.s @@ -4,42 +4,69 @@ ; Written in Sux Assembly ; by mr b0nk 500 +; Variables for thread 0. +.org $1000 +x: +.qword $0 +y: +.qword $0 +z: +.qword $0 +; Variables for thread 1. +.org $2000 +x2: +.qword $0 +y2: +.qword $0 +z2: +.qword $0 + +.org $0 +init: cps ; Clear the Processor Status register. + +start: lda #$0 ; Clear the accumulator. ldy #$1 ; y=1. -sty.q $1008 ; Store y into memory. +sty.q y ; Store y into memory. + +fib: 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. +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 $8000 - +init2: cps ; Clear the Processor Status register. + +start2: 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. +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. ; Set up the thread vectors. .org $FF50 -.qword $8000 +.qword init2 ; Execute the program. done diff --git a/test/test-stack.s b/test/test-stack.s index e31e343..88ed25c 100644 --- a/test/test-stack.s +++ b/test/test-stack.s @@ -1,7 +1,10 @@ +init: cps + +loop: iax pha #$8 ply #$8 -jmp $1 +jmp loop done diff --git a/test/test-the-tests.s b/test/test-the-tests.s index 8471fab..314ed45 100644 --- a/test/test-the-tests.s +++ b/test/test-the-tests.s @@ -1,26 +1,48 @@ .org $0000 +init: cps + +lstart: lda #$01 + +lshft: lsl #$1 -bcs $13 -jmp $3 +bcs rstart +jmp lshft + +rstart: lda.q #$8000000000000000 + +rshft: lsr #$1 -bcs $1 -jmp $1D +bcs lstart +jmp rshft + + .org $8000 +init2: cps + +lstart2: lda #$01 + +lshft2: lsl #$1 -bcs $8013 -jmp $8003 +bcs rstart2 +jmp lshft2 + +rstart2: lda.q #$8000000000000000 + +rshft2: lsr #$1 -bcs $8001 -jmp $801D +bcs lstart2 +jmp rshft2 + +.org $FFC0 +.qword init .org $FF50 -.qword $8000 -.org $0 +.qword init2 done -- cgit v1.2.3-13-gbd6f