Skip to content

Commit 6fb476b

Browse files
committed
fix: fixes TAB routine
1 parent c36efdf commit 6fb476b

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

src/arch/zx48k/library-asm/print.asm

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,20 @@ __PRINT_TAB:
232232

233233
__PRINT_TAB1:
234234
ld (MEM0), a
235-
exx
236235
ld hl, __PRINT_TAB2
237236
jr __PRINT_SET_STATE
238237

239238
__PRINT_TAB2:
240239
ld a, (MEM0) ; Load tab code (ignore the current one)
241-
push hl
242-
push de
243-
push bc
244240
ld hl, __PRINT_START
245241
ld (PRINT_JUMP_STATE), hl
242+
exx
243+
push hl
244+
push bc
245+
push de
246246
call PRINT_TAB
247-
pop bc
248247
pop de
248+
pop bc
249249
pop hl
250250
ret
251251

@@ -496,6 +496,8 @@ PRINT_COMMA:
496496
add a, 16
497497

498498
PRINT_TAB:
499+
; Tabulates the number of spaces in A register
500+
; If the current cursor position is already A, does nothing
499501
PROC
500502
LOCAL LOOP
501503

@@ -507,11 +509,7 @@ PRINT_TAB:
507509
ld b, a
508510
LOOP:
509511
ld a, ' '
510-
push bc
511-
exx
512512
call __PRINTCHAR
513-
exx
514-
pop bc
515513
djnz LOOP
516514
ret
517515
ENDP

src/arch/zxnext/library-asm/print.asm

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,20 @@ __PRINT_TAB:
232232

233233
__PRINT_TAB1:
234234
ld (MEM0), a
235-
exx
236235
ld hl, __PRINT_TAB2
237236
jr __PRINT_SET_STATE
238237

239238
__PRINT_TAB2:
240239
ld a, (MEM0) ; Load tab code (ignore the current one)
241-
push hl
242-
push de
243-
push bc
244240
ld hl, __PRINT_START
245241
ld (PRINT_JUMP_STATE), hl
242+
exx
243+
push hl
244+
push bc
245+
push de
246246
call PRINT_TAB
247-
pop bc
248247
pop de
248+
pop bc
249249
pop hl
250250
ret
251251

@@ -496,6 +496,8 @@ PRINT_COMMA:
496496
add a, 16
497497

498498
PRINT_TAB:
499+
; Tabulates the number of spaces in A register
500+
; If the current cursor position is already A, does nothing
499501
PROC
500502
LOCAL LOOP
501503

@@ -507,11 +509,7 @@ PRINT_TAB:
507509
ld b, a
508510
LOOP:
509511
ld a, ' '
510-
push bc
511-
exx
512512
call __PRINTCHAR
513-
exx
514-
pop bc
515513
djnz LOOP
516514
ret
517515
ENDP

tests/runtime/cases/print_tab.bas

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
INIT("Testing TAB")
44

55
f$=CHR(22,6,27,16,2,17,5,19,1,71) 'PRINT AT 6,27;"G" - fine, so other control codes are not counted
6-
g$=CHR(22,7,10,17,0,23,31,0,32) 'PRINT AT 7,10; INK 0; TAB 31; " " last char is wrong. Should be a space
6+
g$=CHR(22,7,10,17,1,23,31,0,32) 'PRINT AT 7,10; INK 0; TAB 31; " " last char is wrong. Should be a space
77
'PRINT AT 8,31;"-" 'to measure the wrong positions
88
'PRINT a$;b$;c$;d$;e$;f$;g$
99
PRINT f$;g$;
1010
'PRINT AT 10,28;"HI" 'fine at same coords
1111
'PRINT AT 2,0;"--" 'to measure the wrong positions
1212

1313
FINISH
14-
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)