diff --git a/libsrc/cbm/cbm_read.s b/libsrc/cbm/cbm_read.s index b010966a3..a30983302 100644 --- a/libsrc/cbm/cbm_read.s +++ b/libsrc/cbm/cbm_read.s @@ -45,11 +45,11 @@ _cbm_read: - eor #$FF - sta ptr1 - txa - eor #$FF - sta ptr1+1 ; Save -size-1 + inx + stx ptr1+1 + tax + inx + stx ptr1 ; Save size with each byte incremented. jsr popax sta ptr2 @@ -92,9 +92,9 @@ _cbm_read: bne @L3 inc ptr3+1 ; ++bytesread; -@L3: inc ptr1 +@L3: dec ptr1 bne @L1 - inc ptr1+1 + dec ptr1+1 bne @L1 @L4: jsr CLRCH diff --git a/libsrc/cbm/cbm_write.s b/libsrc/cbm/cbm_write.s index 2d932d04a..a199c1d90 100644 --- a/libsrc/cbm/cbm_write.s +++ b/libsrc/cbm/cbm_write.s @@ -39,11 +39,11 @@ _cbm_write: sta ptr3 stx ptr3+1 ; Save size - eor #$FF - sta ptr1 - txa - eor #$FF - sta ptr1+1 ; Save -size-1 + inx + stx ptr1+1 + tax + inx + stx ptr1 ; Save size with each byte incremented jsr popax sta ptr2 @@ -69,9 +69,9 @@ _cbm_write: @L2: jsr BSOUT ; cbm_k_bsout (A); -@L3: inc ptr1 ; --size; +@L3: dec ptr1 ; --size; bne @L1 - inc ptr1+1 + dec ptr1+1 bne @L1 jsr CLRCH diff --git a/libsrc/common/getcwd.s b/libsrc/common/getcwd.s index 22b6ceded..c0a1c3634 100644 --- a/libsrc/common/getcwd.s +++ b/libsrc/common/getcwd.s @@ -17,22 +17,22 @@ .proc _getcwd -; Remember -size-1 because this simplifies the following loop +; Remember size with each byte incremented because this simplifies the following loop - eor #$FF - sta ptr2 - txa - eor #$FF - sta ptr2+1 + inx + stx ptr2+1 + tax + inx + stx ptr2 jsr popptr1 ; Get buf to ptr1 ; Copy __cwd to the given buffer checking the length ; ldy #$00 is guaranteed by popptr1 -loop: inc ptr2 +loop: dec ptr2 bne @L1 - inc ptr2+1 + dec ptr2+1 beq overflow ; Copy one character, end the loop if the zero terminator is reached. We