diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-01-10 16:35:34 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-01-10 16:35:34 -0500 |
commit | 861d56e556b597115ad01b4b4cc0e5b932545ce9 (patch) | |
tree | d24d9718da054658a833b932595819c030065d1a /test | |
parent | 1dfc78b8bf5b708cb1118a9d6646397772a1b894 (diff) |
Added GPLv2.
We're now Free Software!!!
Diffstat (limited to 'test')
-rw-r--r-- | test/asr.s | 6 | ||||
-rw-r--r-- | test/fib2.s | 26 | ||||
-rw-r--r-- | test/ind-addr.s | 27 | ||||
-rw-r--r-- | test/input.s | 195 | ||||
-rw-r--r-- | test/test-stack.s | 3 | ||||
-rw-r--r-- | test/the-tests.s | 35 |
6 files changed, 186 insertions, 106 deletions
@@ -7,15 +7,17 @@ reset: start: lda.q #$-FFFF + ldb.q #-1 signshft: - asr #$1 - cmp.q #$-1 + asr #1 + cab beq start jmp signshft .org $FFC0 .qword reset .org $0 +v done diff --git a/test/fib2.s b/test/fib2.s new file mode 100644 index 0000000..d8c0d42 --- /dev/null +++ b/test/fib2.s @@ -0,0 +1,26 @@ +; Variables for thread 0. +.org $1000 +x: + .qword $0 +y: + .qword $1 +z: + .qword $0 + +.org $0 +init: + cps ; Clear the Processor Status register. + +start: + lda #0 ; Clear the accumulator. + ldb.q y ; b=1. +fib: + aab ; Add x with y. + ldb.q y + stb.q x ; x=y. + sta.q y ; y=z. + tab + lda.q x + bcs start ; Start all over again, if the carry flag was set. + jmp fib ; Otherwise, keep looping. +done diff --git a/test/ind-addr.s b/test/ind-addr.s new file mode 100644 index 0000000..0c9365b --- /dev/null +++ b/test/ind-addr.s @@ -0,0 +1,27 @@ +.org $0 +reset: + cps + lda #1 + ldb #1 +main: + jsr (rot) + jmp main + +rotate_left: + rlb + rts + +rotate_right: + rrb + rts + +.org $1000 +rot: + .qword rotate_left +r +.org $0 +v +.org $1000 +v +done + diff --git a/test/input.s b/test/input.s index 20ab3d1..a8b0830 100644 --- a/test/input.s +++ b/test/input.s @@ -4,22 +4,26 @@ ; mr b0nk 500 <b0nk@b0nk.xyz> +; Input buffer. +.org $4000 +buffer: + ; Initalize some variables. -.org $1000 +.org $0 scr_row: .byte $0 scr_col: .byte $0 a: - .word $0 + .byte $0 b: - .word $0 + .byte $0 c: - .word $0 + .byte $0 d: - .word $0 + .byte $0 e: - .word $0 + .byte $0 string: .byte "Please, type something.\n" string2: @@ -27,9 +31,9 @@ string2: end: .byte $0 -; Input buffer. -.org $0000 -buffer: +; String Pointer +ptr: + .qword buffer ; Main program .org $8000 @@ -37,35 +41,32 @@ reset: cps ldx.w #$FFFF txs - ldy #$0 + ldy #0 + lda #0 clr_buf: - lda #$0 - cpy.w #$1000 + cpy.w #$FFF beq start - sta buffer, y + sta (ptr), y iny jmp clr_buf start: - ldx.w #$0 ; Reset x. - ldy.w #$0 ; Reset y. + tax ; Reset x. + tay ; Reset y. jmp print rset_a: - lda #$10 -delay: - beq read - dec - jmp delay -sleep: - lda end - bne spin ; Are we done with getting input? + lda #1 + read: lda $C000 ; Get control register. beq rset_a ; Loop until we get a character. - lda #$0 + lda #0 sta $C000 jmp getchar ; We got a key. +sleep: + lda end + bne spin ; Are we done with getting input? print: lda string, x ; Get character at offset x. @@ -78,7 +79,7 @@ print: jmp print inc_row: inc scr_row - lda #$0 + lda #0 sta scr_col jmp print ; Keep printing more characters. @@ -88,26 +89,26 @@ getchar: beq esc cmp #$A beq nl ; Did the user type a newline? - cmp #$8 + cmp #8 beq bs ; Did the user type a backspace? cmp #$7F beq bs ; Did the user type a backspace? echo: sta a ldx scr_col - cpx #$4F + cpx #79 bne echo_print linewrap: inc scr_row - ldx #$0 + ldx #0 stx scr_col lda scr_row - jsr update_pos + jsl update_pos echo_print: lda a sta $C001 ; Echo typed character. inc scr_col ; Increment the cursor's x coordinate. - sta buffer, y ; Store typed character into the input buffer. + sta (ptr), y ; Store typed character into the input buffer. iny jmp rset_a ; Start getting user input. @@ -117,22 +118,22 @@ esc: beq read ; We have an error, so discard it, and go back to getting user input. lda $C002 ; Get the escape code. sta c ; Store the escape code, until we need it. - jsr isup ; Check if the user pressed up. + jsl isup ; Check if the user pressed up. lda d - cmp #$0 + cmp #0 bne esc_end - jsr isdown ; Check if the user pressed down. + jsl isdown ; Check if the user pressed down. lda d - cmp #$0 + cmp #0 bne esc_end - lda #$0 - jsr isleft ; Check if the user pressed left. + lda #0 + jsl isleft ; Check if the user pressed left. lda d - cmp #$0 + cmp #0 bne esc_end - jsr isright ; Check if the user pressed right. + jsl isright ; Check if the user pressed right. esc_end: - lda #$0 + lda #0 sta d jmp rset_a ; Go back to getting user input. @@ -143,27 +144,27 @@ isup: cmp #$41 ; Did the user press the up arrow key? beq up ; Yes, so move the cursor up. isup_done: - rts ; End of isup. + rtl ; End of isup. isdown: lda scr_row ; Start checking the y coordinate of the cursor. - cmp #$17 ; Is the cursor at the bottom of the screen? + cmp #23 ; Is the cursor at the bottom of the screen? beq isdown_done ; Yes, so return. lda c ; No, so load the escape code back into the accumulator. cmp #$42 ; Did the user press the down arrow key? beq down ; Yes, so move the cursor down. isdown_done: - rts ; End of isdown. + rtl ; End of isdown. isright: lda scr_col ; Start checking the x coordinate of the cursor. - cmp #$4F ; Is the cursor at the far right of the screen? + cmp #79 ; Is the cursor at the far right of the screen? beq isright_end ; Yes, so return. lda c ; No, so load the escape code back into the accumulator. cmp #$43 ; Did the user press the right arrow key? beq right ; Yes, so move the cursor right. isright_end: - rts ; End of isright. + rtl ; End of isright. isleft: lda scr_col ; Is the cursor at the far left of the screen? @@ -172,36 +173,28 @@ isleft: cmp #$44 ; Did the user press the left arrow key? beq left ; Yes, so move the cursor left. isleft_done: - rts ; End of isleft. + rtl ; End of isleft. up: dec scr_row - lda #$0 - sta e - jsr update_pos - lda #$1 + jsl update_pos + lda #1 sta d jmp isup_done down: inc scr_row - lda #$1 - sta e - jsr update_pos - lda #$1 + jsl update_pos + lda #1 sta d jmp isdown_done right: inc scr_col - lda #$2 - sta e - jsr update_pos + jsl update_pos jmp isright_end left: dec scr_col - lda #$3 - sta e - jsr update_pos - lda #$1 + jsl update_pos + lda #1 sta d jmp isleft_done @@ -210,74 +203,65 @@ update_pos: sta $C001 ; to the screen. lda #$5B ; Print '[' sta $C001 ; to the screen, and start the escape sequence. - jsr getrow ; Start printing the row number to the screen. - jsr getcol ; Start printing the column number to the screen. + jsl getrow ; Start printing the row number to the screen. + jsl getcol ; Start printing the column number to the screen. lda #$48 ; Print 'H' sta $C001 ; to the screen. - rts ; End of update_pos. + rtl ; End of update_pos. getrow: lda scr_row ; Get the cursor's y coordinate. - div #$A ; Divide A by 10. + div #10 ; Divide A by 10. adc #$30 ; Convert it to ascii, and sta $C001 ; print to the screen. tba ; Get the remainder. adc #$30 ; Convert it to ascii, and sta $C001 ; print to the screen. - rts ; End of getrow. + rtl ; End of getrow. getcol: lda #$3B ; Print ';' sta $C001 ; to the screen. lda scr_col ; Get the cursor's x coordinate. - div #$A ; Divide A by 10. + div #10 ; Divide A by 10. adc #$30 ; Convert it to ascii, and sta $C001 ; print to the screen. tba ; Get the remainder. adc #$30 ; Convert it to ascii, and sta $C001 ; print to the screen. - rts ; End of getrow. + rtl ; End of getrow. -uint_to_bcd: - div #$A ; Divide A by 10. - lsl #$4 ; Shift the result left by 4 bits. - sta a ; Store the result for later. - tba ; Get the remainder. - sta b ; Store the remainder for later. - lda a ; Get the result. - ora b ; Or the result, with the remainder. - rts ; We've converted the value to BCD, so return. nl: lda #$A sta $C001 inc scr_row - lda #$0 ; Replace newline with a null terminator. - sta buffer, y ; Store said terminator into the input buffer. + lda #0 ; Replace newline with a null terminator. + sta (ptr), y ; Store said terminator into the input buffer. sta scr_col - ldy.w #$0 ; Reset y, to print the result. + ldy.w #0 ; Reset y, to print the result. jmp result back: sta $C001 ; Print backspace. - lda #$0 ; Put a null terminator, in place of the backspace. - sta buffer, y ; Place it into the input buffer. + lda #0 ; Put a null terminator, in place of the backspace. + sta (ptr), y ; Place it into the input buffer. dey ; Decrement buffer offset. dec scr_col jmp read ; Get next character. bs: - cpy #$0 ; Are we at the start of the buffer? + cpy #0 ; Are we at the start of the buffer? beq rset_a ; We are, so do not store the backspace into the buffer. jmp back ; We are not, so add the backspace to the buffer. result: ldx scr_col - cpx #$4F + cpx #79 bne result_print linewrap2: inc scr_row ldx #$0 stx scr_col - jsr update_pos + jsl update_pos result_print: lda string2, y beq rset_y ; Reset y, if we hit the null terminator. @@ -288,20 +272,20 @@ result_print: rset_y: - ldy.w #$0 ; Reset y. + ldy.w #0 ; Reset y. jmp print_buf ; Print the input buffer. print_buf: ldx scr_col - cpx #$4F + cpx #79 bne buf_print linewrap3: inc scr_row - ldx #$0 + ldx #0 stx scr_col - jsr update_pos + jsl update_pos buf_print: - lda buffer, y ; Get a character from the input buffer. + lda (ptr), y ; Get a character from the input buffer. beq spin ; Are we done with printing the buffer? sta $C001 ; Print said character. inc scr_col ; Increment the cursor's x coordinate. @@ -310,11 +294,11 @@ buf_print: scr_to_buf: tax - mul #$50 + mul #80 adc scr_col tay txa - rts + rtl spin: nop @@ -322,6 +306,20 @@ spin: nop jmp spin +.org $1000 +v +.org $1100 +v +.org $1200 +v +.org $8000 +v +.org $8100 +v +.org $8200 +v +.org $8300 +v .org $FFC0 .qword reset @@ -333,15 +331,8 @@ spin: .qword spin .qword spin .qword spin - -.org $FFA0 -.qword irq_routine -;.org $8000 -;viewmem -;.org $8100 -;viewmem -;.org $8200 -;viewmem -;q -done +.org $FF50 +v +;done +q diff --git a/test/test-stack.s b/test/test-stack.s index 5c7e0fd..193cca7 100644 --- a/test/test-stack.s +++ b/test/test-stack.s @@ -2,10 +2,9 @@ init: cps ldx.w #$FFFF txs -ldx.d #$00 loop: -iax +iab pha #$08 ply #$08 jmp loop diff --git a/test/the-tests.s b/test/the-tests.s new file mode 100644 index 0000000..ae31e26 --- /dev/null +++ b/test/the-tests.s @@ -0,0 +1,35 @@ +.org $0 +init: + cps + +lstart: + lda #1 + tab + +lshft: + llb + bcs rstart + jmp lshft + +rstart: + tba + lsl #63 + +rshft: + lrb + bcs lstart + jmp rshft + +.org $FFC0 +.qword init + +.org $FF50 +.qword init +.qword init +.qword init +.qword init +.qword init +.qword init +.qword init +.qword init +done |