From 607ca37ab87095ac5d79f9a1646a253df633c2e3 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 8 May 2021 15:01:36 -0400 Subject: Fixed a bug in print_str to do with clobbered registers. This was due to print_char clobbering `d` when calling get_index. --- programs/sub-suite/subeditor.s | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s index 4723b60..6e603ae 100644 --- a/programs/sub-suite/subeditor.s +++ b/programs/sub-suite/subeditor.s @@ -147,25 +147,28 @@ getchar: print_str: pha.q ; Preserve A. phb.q ; Preserve B. + phx.q ; Preserve X. and #0 ; Reset A. - tba ; Reset B. + mov b, d ; Get the string pointer. + tax ; Reset X. @loop: mov regb, #1 ; Enable replace mode. - and #0 ; Reset A. - mov b, (d) ; Are we at the end of the string? + xor d, d ; Reset D. + mov d, (b+x) ; Are we at the end of the string? beq @end ; Yes, so we're done. jsr update_ptr ; No, so get the screen buffer index. tay ; Save it in Y. - tba ; Get the character back. - inc d ; Increment the string pointer. + mov a, d ; Get the character back. + inx ; Increment the index. jsr print_char ; Print the character. bra @loop ; Keep looping. @end: stz regb ; Enable insert mode. and #0 ; Reset A. tab ; Reset B. - pla.q ; Restore A. + plx.q ; Restore X. plb.q ; Restore B. + pla.q ; Restore A. rts ; End of print_str. -- cgit v1.2.3-13-gbd6f