diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-05-08 15:01:36 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-05-08 15:01:36 -0400 |
commit | 607ca37ab87095ac5d79f9a1646a253df633c2e3 (patch) | |
tree | 5568cee51cb88bf3fbf3aa61ad7af062f8288f84 /programs | |
parent | 01c8e7399cc940d2d5d0540593e16724948bd6e3 (diff) |
Fixed a bug in print_str to do with clobbered
registers.
This was due to print_char clobbering `d` when calling
get_index.
Diffstat (limited to 'programs')
-rw-r--r-- | programs/sub-suite/subeditor.s | 15 |
1 files 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. |