From 3029d54edf8baabb2841f9a6f3d88bfc993ae3e8 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 19 Dec 2019 01:02:09 -0500 Subject: Added the B register, which is used for storing the remainder during a DIV instruction. I also added the TAB, and TBA instructions, for transfering between the Accumulator, and the B register. --- test/input.s | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/input.s b/test/input.s index a2725f6..95b4077 100644 --- a/test/input.s +++ b/test/input.s @@ -12,10 +12,15 @@ string2: .byte "You typed, " end: .byte $0 -x: +scr_row: .word $0 -tmp: +scr_col: .word $0 +a: + .word $0 +b: + .word $0 + ; Input buffer. .org $2000 buffer: @@ -93,6 +98,10 @@ esc: cmp #$44 ; Did the user press the left arrow? beq left ; Yes, so move the cursor left. up: + lda scr_row + beq rset_a + dec scr_row + jsr update_pos lda #$1B sta $C001 lda #$5B @@ -101,6 +110,8 @@ up: sta $C001 jmp rset_a down: + inc scr_row + jsr update_pos lda #$1B sta $C001 lda #$5B @@ -109,6 +120,11 @@ down: sta $C001 jmp rset_a right: + lda scr_col + cmp #$50 + beq rset_a + inc scr_col + jsr update_pos lda #$1B sta $C001 lda #$5B @@ -117,6 +133,10 @@ right: sta $C001 jmp rset_a left: + lda scr_col + beq rset_a + dec scr_col + jsr update_pos lda #$1B sta $C001 lda #$5B @@ -125,8 +145,30 @@ left: sta $C001 jmp rset_a +update_pos: + lda #$1B + sta $C001 + lda #$5B + sta $C001 + lda scr_row + jsr uint_to_bcd + jmp spin + +uint_to_bcd: + div #$A + lsl #$4 + sta a + tba + sta b + lda a + ora b + rts + nl: + lda #$A sta $C001 + inc scr_row + jsr update_pos lda #$0 ; Replace newline with a null terminator. sta buffer, y ; Store said terminator into the input buffer. ldy.w #$0 ; Reset y, to print the result. @@ -189,3 +231,4 @@ viewmem viewmem ;q done + -- cgit v1.2.3-13-gbd6f