Skip to content

Commit 381114a

Browse files
authored
Merge pull request #460 from boriel/bugfix/PRINT_COMMA
Bugfix/print comma
2 parents d935c46 + a26b18a commit 381114a

71 files changed

Lines changed: 977 additions & 765 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,8 @@ INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
179179
ld hl, (MAXX)
180180
ld a, e
181181
dec l ; l = MAXX
182-
cp l ; Lower than max?
183-
jp c, __PRINT_CONT; Nothing to do
184-
call __PRINT_EOL1
185-
exx ; counteracts __PRINT_EOL1 exx
186-
jp __PRINT_CONT2
182+
cp l ; Lower than max?
183+
jp nc, __PRINT_EOL1
187184

188185
__PRINT_CONT:
189186
call __SAVE_S_POSN
@@ -218,7 +215,7 @@ __PRINT_EOL2:
218215

219216
__PRINT_AT1_END:
220217
ld hl, (MAXY)
221-
cp h
218+
cp l
222219
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
223220
#ifndef DISABLE_SCROLL
224221
ld hl, __TVFLAGS
@@ -459,7 +456,11 @@ CONTINUE:
459456
ld b, a
460457
LOOP:
461458
ld a, ' '
459+
push bc
460+
exx
462461
call __PRINTCHAR
462+
exx
463+
pop bc
463464
djnz LOOP
464465
ret
465466
ENDP

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include once <alloc.asm>
21
#include once <free.asm>
32

43
#ifndef HIDE_LOAD_MSG
@@ -26,12 +25,14 @@ LOAD_CODE:
2625
LOCAL LOAD_END
2726
LOCAL VR_CONTROL, VR_CONT_1, VR_CONT_2
2827
LOCAL MEM0
28+
LOCAL TMP_SP
2929

3030
MEM0 EQU 5C92h ; Temporary memory buffer
3131
HEAD1 EQU MEM0 + 8 ; Uses CALC Mem for temporary storage
3232
; Must skip first 8 bytes used by
3333
; PRINT routine
3434
TMP_HEADER EQU HEAD1 + 17 ; Temporary HEADER2 pointer storage
35+
TMP_SP EQU TMP_HEADER + 2 ; Temporary SP storage
3536

3637
#ifdef __ENABLE_BREAK__
3738
LD_BYTES EQU 0556h ; ROM Routine LD-BYTES
@@ -59,6 +60,8 @@ __LOAD_CODE: ; INLINE version
5960
ld (ix + 13), e
6061
ld (ix + 14), d ; Store address in bytes
6162

63+
push hl ; String ptr to be freed later
64+
6265
ld a, h
6366
or l
6467
ld b, h
@@ -99,15 +102,15 @@ LOAD_CONT:
99102
ldir ; Copy String block NAME in header
100103

101104
LOAD_CONT2:
102-
ld bc, 17; 2nd Header
103-
call __MEM_ALLOC
105+
pop hl ; String ptr
106+
call MEM_FREE
104107

105-
ld a, h
106-
or l
107-
jr nz, LOAD_CONT3; there's memory
108-
109-
ld a, ERROR_OutOfMemory
110-
jp __ERROR
108+
ld hl, 0
109+
add hl, sp
110+
ld (TMP_SP), hl
111+
ld bc, -18
112+
add hl, sp
113+
ld sp, hl
111114

112115
LOAD_CONT3:
113116
ld (TMP_HEADER), hl
@@ -239,9 +242,10 @@ LOAD_ERROR:
239242
ld (ERR_NR), a
240243

241244
LOAD_END:
245+
ld hl, (TMP_SP)
246+
ld sp, hl ; Recovers stack
242247
pop ix ; Recovers stack frame pointer
243-
ld hl, (TMP_HEADER) ; Recovers tmp_header pointer
244-
jp MEM_FREE ; Returns via FREE_MEM, freeing tmp header
248+
ret
245249

246250
#ifndef __ENABLE_BREAK__
247251
LOCAL LD_BYTES_RET

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,8 @@ INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
179179
ld hl, (MAXX)
180180
ld a, e
181181
dec l ; l = MAXX
182-
cp l ; Lower than max?
183-
jp c, __PRINT_CONT; Nothing to do
184-
call __PRINT_EOL1
185-
exx ; counteracts __PRINT_EOL1 exx
186-
jp __PRINT_CONT2
182+
cp l ; Lower than max?
183+
jp nc, __PRINT_EOL1
187184

188185
__PRINT_CONT:
189186
call __SAVE_S_POSN
@@ -218,7 +215,7 @@ __PRINT_EOL2:
218215

219216
__PRINT_AT1_END:
220217
ld hl, (MAXY)
221-
cp h
218+
cp l
222219
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
223220
#ifndef DISABLE_SCROLL
224221
ld hl, __TVFLAGS
@@ -459,7 +456,11 @@ CONTINUE:
459456
ld b, a
460457
LOOP:
461458
ld a, ' '
459+
push bc
460+
exx
462461
call __PRINTCHAR
462+
exx
463+
pop bc
463464
djnz LOOP
464465
ret
465466
ENDP

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ TAKE_FRAMES:
2929
FRAMES EQU 23672
3030
ENDP
3131

32-
RANDOM_SEED_HIGH EQU RAND+6 ; RANDOM seed, 16 higher bits
33-
RANDOM_SEED_LOW EQU 23670 ; RANDOM seed, 16 lower bits
32+
RANDOM_SEED_HIGH EQU RAND+6 ; RANDOM seed, 16 higher bits
33+
RANDOM_SEED_LOW EQU 23670 ; RANDOM seed, 16 lower bits
3434

3535

3636
RAND:
@@ -54,18 +54,17 @@ RAND_LOOP:
5454
rra ; t = t ^ (t >> 1) ^ w
5555
xor d
5656
xor e
57-
ld h,l ; y = z
58-
ld l,a ; w = t
59-
ld (RANDOM_SEED_HIGH),hl
57+
ld d,l ; y = z
58+
ld e,a ; w = t
59+
ld (RANDOM_SEED_HIGH),de
6060
push af
6161
djnz RAND_LOOP
62-
pop af
63-
pop af
64-
ld d, a
62+
pop de
6563
pop af
6664
ld e, a
65+
pop hl
6766
pop af
68-
ld h, a
67+
ld l, a
6968
ret
7069
ENDP
7170

@@ -89,7 +88,7 @@ RND:
8988
; We already have a random 32 bit mantissa in ED CB
9089
; From 0001h to FFFFh
9190

92-
ld l, 81h ; Exponent
91+
ld l, 81h ; Exponent
9392
; At this point we have [0 .. 1) FP number;
9493

9594
; Now we must shift mantissa left until highest bit goes into carry

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
; YYY and ZZZ are 16 bit on top of the stack.
55

66
#include once <error.asm>
7+
#include once <free.asm>
78

89
SAVE_CODE:
910

@@ -14,16 +15,20 @@ SAVE_CODE:
1415
LOCAL ROM_SAVE
1516
LOCAL __ERR_EMPTY
1617
LOCAL SAVE_STOP
18+
LOCAL STR_PTR
19+
LOCAL SAVE_EMPTY_ERROR
1720

1821
#ifdef __ENABLE_BREAK__
1922
ROM_SAVE EQU 0970h
2023
#endif
2124
MEMBOT EQU 23698 ; Use the CALC mem to store header
25+
STR_PTR EQU MEMBOT + 17
2226

2327
pop hl ; Return address
2428
pop bc ; data length in bytes
2529
pop de ; address start
2630
ex (sp), hl ; CALLE => now hl = String
31+
ld (STR_PTR), hl
2732

2833
; This function will call the ROM SAVE CODE Routine
2934
; Parameters in the stack are HL => String with SAVE name
@@ -34,7 +39,7 @@ SAVE_CODE:
3439
__SAVE_CODE: ; INLINE version
3540
ld a, b
3641
or c
37-
ret z ; Return if block length == 0
42+
jr z, SAVE_EMPTY_ERROR ; Return if block length == 0
3843
3944
push ix
4045
ld a, h
@@ -79,6 +84,8 @@ __ERR_EMPTY:
7984
SAVE_CONT:
8085
ld de, MEMBOT + 1
8186
ldir ; Copy String block NAME
87+
ld hl, (STR_PTR)
88+
call MEM_FREE
8289
ld l, (ix + 13)
8390
ld h, (ix + 14) ; Restores start of bytes
8491

@@ -97,8 +104,15 @@ NO_INT:
97104
pop ix
98105
ret
99106

107+
SAVE_EMPTY_ERROR:
108+
ld a, ERROR_InvalidArg
109+
100110
SAVE_STOP:
101111
pop ix
112+
push af
113+
ld hl, (STR_PTR)
114+
call MEM_FREE
115+
pop af
102116
jp __STOP
103117

104118
#ifndef __ENABLE_BREAK__

tests/functional/astore16.asm

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ __END_PROGRAM:
111111
ret
112112
__CALL_BACK__:
113113
DEFW 0
114+
;; --- end of user code ---
114115
#line 1 "/zxbasic/src/arch/zx48k/library-asm/array.asm"
115116
; vim: ts=4:et:sw=4:
116117
; Copyleft (K) by Jose M. Rodriguez de la Rosa
@@ -239,7 +240,7 @@ __FNMUL2:
239240
TMP_ARR_PTR:
240241
DW 0 ; temporary storage for pointer to tables
241242
ENDP
242-
#line 52 "astore16.bas"
243+
#line 53 "astore16.bas"
243244
#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
244245
; vim:ts=4:sw=4:et:
245246
; vim:ts=4:sw=4:et:
@@ -880,11 +881,8 @@ INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
880881
ld hl, (MAXX)
881882
ld a, e
882883
dec l ; l = MAXX
883-
cp l ; Lower than max?
884-
jp c, __PRINT_CONT; Nothing to do
885-
call __PRINT_EOL1
886-
exx ; counteracts __PRINT_EOL1 exx
887-
jp __PRINT_CONT2
884+
cp l ; Lower than max?
885+
jp nc, __PRINT_EOL1
888886
__PRINT_CONT:
889887
call __SAVE_S_POSN
890888
__PRINT_CONT2:
@@ -899,7 +897,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence
899897
exx
900898
__PRINT_0Dh: ; Called WHEN printing CHR$(13)
901899
call __SCROLL
902-
#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
900+
#line 207 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
903901
call __LOAD_S_POSN
904902
__PRINT_EOL1: ; Another entry called from PRINT when next line required
905903
ld e, 0
@@ -908,12 +906,12 @@ __PRINT_EOL2:
908906
inc a
909907
__PRINT_AT1_END:
910908
ld hl, (MAXY)
911-
cp h
909+
cp l
912910
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
913911
ld hl, __TVFLAGS
914912
set 1, (hl)
915913
dec a
916-
#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
914+
#line 227 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
917915
__PRINT_EOL_END:
918916
ld d, a
919917
__PRINT_AT2_END:
@@ -1111,7 +1109,11 @@ CONTINUE:
11111109
ld b, a
11121110
LOOP:
11131111
ld a, ' '
1112+
push bc
1113+
exx
11141114
call __PRINTCHAR
1115+
exx
1116+
pop bc
11151117
djnz LOOP
11161118
ret
11171119
ENDP
@@ -1126,7 +1128,7 @@ PRINT_AT: ; Changes cursor to ROW, COL
11261128
ret nc ; Return if out of screen
11271129
ld hl, __TVFLAGS
11281130
res 1, (hl)
1129-
#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
1131+
#line 483 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
11301132
jp __SAVE_S_POSN
11311133
LOCAL __PRINT_COM
11321134
LOCAL __BOLD
@@ -1172,7 +1174,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes
11721174
DW __PRINT_AT ; 22 AT
11731175
DW __PRINT_TAB ; 23 TAB
11741176
ENDP
1175-
#line 53 "astore16.bas"
1177+
#line 54 "astore16.bas"
11761178
#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu16.asm"
11771179
#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi16.asm"
11781180
#line 1 "/zxbasic/src/arch/zx48k/library-asm/printnum.asm"
@@ -1312,5 +1314,5 @@ __PRINTU_LOOP:
13121314
jp __PRINTU_LOOP ; Uses JP in loops
13131315
ENDP
13141316
#line 2 "/zxbasic/src/arch/zx48k/library-asm/printu16.asm"
1315-
#line 54 "astore16.bas"
1317+
#line 55 "astore16.bas"
13161318
END

0 commit comments

Comments
 (0)