Skip to content

Commit 4614fe9

Browse files
committed
Add tests
This test also that the include [arch:zx48k] works. Also refactorize other tests.
1 parent f33f869 commit 4614fe9

Some content is hidden

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

44 files changed

+9820
-46
lines changed

src/arch/z80/optimizer/cpustate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ def set(self, r: str, val: int | str | None) -> None:
417417

418418
if is_unknown8(val):
419419
val = f"{new_tmp_val()}{HL_SEP}{val}"
420-
assert (
421-
is_num or is_unknown16(val) or is_label(val)
422-
), f"val '{val}' is neither a number, nor a label nor an unknown16"
420+
assert is_num or is_unknown16(val) or is_label(val), (
421+
f"val '{val}' is neither a number, nor a label nor an unknown16"
422+
)
423423

424424
self.regs[r] = val
425425
if is_16bit_composed_register(r): # sp register is not included. Special case

src/zxbasm/memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ def declare_label(
229229

230230
fname = gl.FILENAME
231231
if label.isdecimal(): # Temporary label?
232-
assert (
233-
not self._tmp_labels_lines[fname] or self._tmp_labels_lines[fname][-1] <= lineno
234-
), "Temporary label out of order"
232+
assert not self._tmp_labels_lines[fname] or self._tmp_labels_lines[fname][-1] <= lineno, (
233+
"Temporary label out of order"
234+
)
235235
if not self._tmp_labels_lines[fname] or self._tmp_labels_lines[fname][-1] != lineno:
236236
self._tmp_labels_lines[fname].append(lineno)
237237

tests/functional/arch/zxnext/array03.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ _a.__DATA__:
7575
; ((aN-1 * bN-2) + aN-2) * bN-3 + ...
7676
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
7777
push namespace core
78-
__MUL16: ; Mutiplies HL with the last value stored into de stack
78+
__MUL16: ; Multiplies HL with the last value stored into de stack
7979
; Works for both signed and unsigned
8080
PROC
8181
ex de, hl

tests/functional/arch/zxnext/array06.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ _a.__DATA__:
8686
; ((aN-1 * bN-2) + aN-2) * bN-3 + ...
8787
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
8888
push namespace core
89-
__MUL16: ; Mutiplies HL with the last value stored into de stack
89+
__MUL16: ; Multiplies HL with the last value stored into de stack
9090
; Works for both signed and unsigned
9191
PROC
9292
ex de, hl

tests/functional/arch/zxnext/array07.asm

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ _test__leave:
111111
; ((aN-1 * bN-2) + aN-2) * bN-3 + ...
112112
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
113113
push namespace core
114-
__MUL16: ; Mutiplies HL with the last value stored into de stack
114+
__MUL16: ; Multiplies HL with the last value stored into de stack
115115
; Works for both signed and unsigned
116116
PROC
117117
ex de, hl
@@ -252,7 +252,7 @@ __FNMUL2:
252252
ENDP
253253
pop namespace
254254
#line 41 "arch/zxnext/array07.bas"
255-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm"
255+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/free.asm"
256256
; vim: ts=4:et:sw=4:
257257
; Copyleft (K) by Jose M. Rodriguez de la Rosa
258258
; (a.k.a. Boriel)
@@ -312,7 +312,7 @@ __FNMUL2:
312312
; HL = BLOCK Start & DE = Length.
313313
; An init directive is useful for initialization routines.
314314
; They will be added automatically if needed.
315-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/heapinit.asm"
315+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/heapinit.asm"
316316
; vim: ts=4:et:sw=4:
317317
; Copyleft (K) by Jose M. Rodriguez de la Rosa
318318
; (a.k.a. Boriel)
@@ -419,7 +419,7 @@ __MEM_INIT2:
419419
ret
420420
ENDP
421421
pop namespace
422-
#line 69 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm"
422+
#line 69 "/zxbasic/src/lib/arch/zxnext/runtime/mem/free.asm"
423423
; ---------------------------------------------------------------------
424424
; MEM_FREE
425425
; Frees a block of memory
@@ -531,7 +531,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
531531
; This function will resize (REALLOC) the space pointed by HL
532532
; before copying the content of b$ into a$
533533
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/strcpy.asm"
534-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
534+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
535535
; vim: ts=4:et:sw=4:
536536
; Copyleft (K) by Jose M. Rodriguez de la Rosa
537537
; (a.k.a. Boriel)
@@ -625,8 +625,19 @@ __STOP:
625625
ld (ERR_NR), a
626626
ret
627627
pop namespace
628-
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
629-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
628+
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
629+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/alloc.asm"
630+
; vim: ts=4:et:sw=4:
631+
; Copyleft (K) by Jose M. Rodriguez de la Rosa
632+
; (a.k.a. Boriel)
633+
; http://www.boriel.com
634+
;
635+
; This ASM library is licensed under the MIT license
636+
; you can use it for any purpose (even for commercial
637+
; closed source programs).
638+
;
639+
; Please read the MIT license on the internet
640+
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
630641
; vim: ts=4:et:sw=4:
631642
; Copyleft (K) by Jose M. Rodriguez de la Rosa
632643
; (a.k.a. Boriel)
@@ -716,9 +727,9 @@ __MEM_START:
716727
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
717728
ld a, h ; HL = NULL (No memory available?)
718729
or l
719-
#line 113 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
730+
#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
720731
ret z ; NULL
721-
#line 115 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
732+
#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
722733
; HL = Pointer to Free block
723734
ld e, (hl)
724735
inc hl
@@ -783,7 +794,8 @@ __MEM_SUBTRACT:
783794
ret
784795
ENDP
785796
pop namespace
786-
#line 71 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
797+
#line 13 "/zxbasic/src/lib/arch/zxnext/runtime/mem/alloc.asm"
798+
#line 71 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
787799
; ---------------------------------------------------------------------
788800
; MEM_REALLOC
789801
; Reallocates a block of memory in the heap.

tests/functional/arch/zxnext/array08.asm

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ _a.__DATA__:
9191
; ((aN-1 * bN-2) + aN-2) * bN-3 + ...
9292
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
9393
push namespace core
94-
__MUL16: ; Mutiplies HL with the last value stored into de stack
94+
__MUL16: ; Multiplies HL with the last value stored into de stack
9595
; Works for both signed and unsigned
9696
PROC
9797
ex de, hl
@@ -244,7 +244,7 @@ __FNMUL2:
244244
; This function will resize (REALLOC) the space pointed by HL
245245
; before copying the content of b$ into a$
246246
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/strcpy.asm"
247-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
247+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
248248
; vim: ts=4:et:sw=4:
249249
; Copyleft (K) by Jose M. Rodriguez de la Rosa
250250
; (a.k.a. Boriel)
@@ -338,8 +338,19 @@ __STOP:
338338
ld (ERR_NR), a
339339
ret
340340
pop namespace
341-
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
342-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
341+
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
342+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/alloc.asm"
343+
; vim: ts=4:et:sw=4:
344+
; Copyleft (K) by Jose M. Rodriguez de la Rosa
345+
; (a.k.a. Boriel)
346+
; http://www.boriel.com
347+
;
348+
; This ASM library is licensed under the MIT license
349+
; you can use it for any purpose (even for commercial
350+
; closed source programs).
351+
;
352+
; Please read the MIT license on the internet
353+
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
343354
; vim: ts=4:et:sw=4:
344355
; Copyleft (K) by Jose M. Rodriguez de la Rosa
345356
; (a.k.a. Boriel)
@@ -399,7 +410,7 @@ __STOP:
399410
; HL = BLOCK Start & DE = Length.
400411
; An init directive is useful for initialization routines.
401412
; They will be added automatically if needed.
402-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/heapinit.asm"
413+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/heapinit.asm"
403414
; vim: ts=4:et:sw=4:
404415
; Copyleft (K) by Jose M. Rodriguez de la Rosa
405416
; (a.k.a. Boriel)
@@ -506,7 +517,7 @@ __MEM_INIT2:
506517
ret
507518
ENDP
508519
pop namespace
509-
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
520+
#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
510521
; ---------------------------------------------------------------------
511522
; MEM_ALLOC
512523
; Allocates a block of memory in the heap.
@@ -537,9 +548,9 @@ __MEM_START:
537548
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
538549
ld a, h ; HL = NULL (No memory available?)
539550
or l
540-
#line 113 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
551+
#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
541552
ret z ; NULL
542-
#line 115 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
553+
#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
543554
; HL = Pointer to Free block
544555
ld e, (hl)
545556
inc hl
@@ -604,8 +615,9 @@ __MEM_SUBTRACT:
604615
ret
605616
ENDP
606617
pop namespace
607-
#line 71 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
608-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm"
618+
#line 13 "/zxbasic/src/lib/arch/zxnext/runtime/mem/alloc.asm"
619+
#line 71 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
620+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/free.asm"
609621
; vim: ts=4:et:sw=4:
610622
; Copyleft (K) by Jose M. Rodriguez de la Rosa
611623
; (a.k.a. Boriel)
@@ -763,7 +775,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
763775
ret
764776
ENDP
765777
pop namespace
766-
#line 72 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
778+
#line 72 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
767779
; ---------------------------------------------------------------------
768780
; MEM_REALLOC
769781
; Reallocates a block of memory in the heap.

tests/functional/arch/zxnext/array09.asm

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ _a.__DATA__:
9191
; ((aN-1 * bN-2) + aN-2) * bN-3 + ...
9292
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
9393
push namespace core
94-
__MUL16: ; Mutiplies HL with the last value stored into de stack
94+
__MUL16: ; Multiplies HL with the last value stored into de stack
9595
; Works for both signed and unsigned
9696
PROC
9797
ex de, hl
@@ -244,7 +244,7 @@ __FNMUL2:
244244
; This function will resize (REALLOC) the space pointed by HL
245245
; before copying the content of b$ into a$
246246
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/strcpy.asm"
247-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
247+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
248248
; vim: ts=4:et:sw=4:
249249
; Copyleft (K) by Jose M. Rodriguez de la Rosa
250250
; (a.k.a. Boriel)
@@ -338,8 +338,19 @@ __STOP:
338338
ld (ERR_NR), a
339339
ret
340340
pop namespace
341-
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
342-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
341+
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
342+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/alloc.asm"
343+
; vim: ts=4:et:sw=4:
344+
; Copyleft (K) by Jose M. Rodriguez de la Rosa
345+
; (a.k.a. Boriel)
346+
; http://www.boriel.com
347+
;
348+
; This ASM library is licensed under the MIT license
349+
; you can use it for any purpose (even for commercial
350+
; closed source programs).
351+
;
352+
; Please read the MIT license on the internet
353+
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
343354
; vim: ts=4:et:sw=4:
344355
; Copyleft (K) by Jose M. Rodriguez de la Rosa
345356
; (a.k.a. Boriel)
@@ -399,7 +410,7 @@ __STOP:
399410
; HL = BLOCK Start & DE = Length.
400411
; An init directive is useful for initialization routines.
401412
; They will be added automatically if needed.
402-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/heapinit.asm"
413+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/heapinit.asm"
403414
; vim: ts=4:et:sw=4:
404415
; Copyleft (K) by Jose M. Rodriguez de la Rosa
405416
; (a.k.a. Boriel)
@@ -506,7 +517,7 @@ __MEM_INIT2:
506517
ret
507518
ENDP
508519
pop namespace
509-
#line 70 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
520+
#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
510521
; ---------------------------------------------------------------------
511522
; MEM_ALLOC
512523
; Allocates a block of memory in the heap.
@@ -537,9 +548,9 @@ __MEM_START:
537548
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
538549
ld a, h ; HL = NULL (No memory available?)
539550
or l
540-
#line 113 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
551+
#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
541552
ret z ; NULL
542-
#line 115 "/zxbasic/src/lib/arch/zxnext/runtime/alloc.asm"
553+
#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/mem/alloc.asm"
543554
; HL = Pointer to Free block
544555
ld e, (hl)
545556
inc hl
@@ -604,8 +615,9 @@ __MEM_SUBTRACT:
604615
ret
605616
ENDP
606617
pop namespace
607-
#line 71 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
608-
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm"
618+
#line 13 "/zxbasic/src/lib/arch/zxnext/runtime/mem/alloc.asm"
619+
#line 71 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
620+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/mem/free.asm"
609621
; vim: ts=4:et:sw=4:
610622
; Copyleft (K) by Jose M. Rodriguez de la Rosa
611623
; (a.k.a. Boriel)
@@ -763,7 +775,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
763775
ret
764776
ENDP
765777
pop namespace
766-
#line 72 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm"
778+
#line 72 "/zxbasic/src/lib/arch/zxnext/runtime/mem/realloc.asm"
767779
; ---------------------------------------------------------------------
768780
; MEM_REALLOC
769781
; Reallocates a block of memory in the heap.

tests/functional/arch/zxnext/mul16.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ _b:
4444
;; --- end of user code ---
4545
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
4646
push namespace core
47-
__MUL16: ; Mutiplies HL with the last value stored into de stack
47+
__MUL16: ; Multiplies HL with the last value stored into de stack
4848
; Works for both signed and unsigned
4949
PROC
5050
ex de, hl

tests/functional/arch/zxnext/mul16a.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _a:
3737
;; --- end of user code ---
3838
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
3939
push namespace core
40-
__MUL16: ; Mutiplies HL with the last value stored into de stack
40+
__MUL16: ; Multiplies HL with the last value stored into de stack
4141
; Works for both signed and unsigned
4242
PROC
4343
ex de, hl

tests/functional/arch/zxnext/mul16b.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _a:
4343
;; --- end of user code ---
4444
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arith/mul16.asm"
4545
push namespace core
46-
__MUL16: ; Mutiplies HL with the last value stored into de stack
46+
__MUL16: ; Multiplies HL with the last value stored into de stack
4747
; Works for both signed and unsigned
4848
PROC
4949
ex de, hl

0 commit comments

Comments
 (0)