diff --git a/src/arch/z80/backend/generic.py b/src/arch/z80/backend/generic.py index 691923d1d..04767f1b1 100644 --- a/src/arch/z80/backend/generic.py +++ b/src/arch/z80/backend/generic.py @@ -272,12 +272,13 @@ def _larrd(ins: Quad): if not isinstance(bounds, list) or len(bounds) not in (0, 2): raise InvalidIC(ins, "Bounds list length must be 0 or 2, not %s" % ins[5]) - if bounds: + have_bounds = bounds and any(x != "0" for x in bounds) + if have_bounds: output.extend( [ - "ld hl, %s" % bounds[1], + "ld hl, %s" % bounds[1], # UBOUND Table PTR "push hl", - "ld hl, %s" % bounds[0], + "ld hl, %s" % bounds[0], # LBOUND Table PTR "push hl", ] ) @@ -297,12 +298,12 @@ def _larrd(ins: Quad): ) if must_initialize: - if not bounds: + if not have_bounds: output.append(runtime_call(RuntimeLabel.ALLOC_INITIALIZED_LOCAL_ARRAY)) else: output.append(runtime_call(RuntimeLabel.ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS)) else: - if not bounds: + if not have_bounds: output.append(runtime_call(RuntimeLabel.ALLOC_LOCAL_ARRAY)) else: output.append(runtime_call(RuntimeLabel.ALLOC_LOCAL_ARRAY_WITH_BOUNDS)) diff --git a/src/arch/z80/visitor/function_translator.py b/src/arch/z80/visitor/function_translator.py index 856ddd072..b2b94a0b0 100644 --- a/src/arch/z80/visitor/function_translator.py +++ b/src/arch/z80/visitor/function_translator.py @@ -55,22 +55,22 @@ def visit_FUNCTION(self, node): # if self.O_LEVEL > 1: # return + if local_var.class_ == CLASS.const or local_var.scope == SCOPE.parameter: + continue + if local_var.class_ == CLASS.array and local_var.scope == SCOPE.local: - bound_ptrs = [] # Bound tables pointers (empty if not used) lbound_label = local_var.mangled + ".__LBOUND__" ubound_label = local_var.mangled + ".__UBOUND__" + lbound_needed = not local_var.is_zero_based and local_var.is_dynamically_accessed - if local_var.lbound_used or local_var.ubound_used: - bound_ptrs = ["0", "0"] # NULL by default - if local_var.lbound_used: - bound_ptrs[0] = lbound_label - if local_var.ubound_used: - bound_ptrs[1] = ubound_label + bound_ptrs = [lbound_label if lbound_needed else "0", "0"] + if local_var.ubound_used: + bound_ptrs[1] = ubound_label - if bound_ptrs: + if bound_ptrs != ["0", "0"]: OPTIONS["__DEFINES"].value["__ZXB_USE_LOCAL_ARRAY_WITH_BOUNDS__"] = "" - if local_var.lbound_used: + if lbound_needed: l = ["%04X" % bound.lower for bound in local_var.bounds] bound_tables.append(LabelledData(lbound_label, l)) @@ -89,8 +89,7 @@ def visit_FUNCTION(self, node): if local_var.default_value is not None: r.extend(self.array_default_value(local_var.type_, local_var.default_value)) self.ic_larrd(local_var.offset, q, local_var.size, r, bound_ptrs) # Initializes array bounds - elif local_var.class_ == CLASS.const or local_var.scope == SCOPE.parameter: - continue + else: # Local vars always defaults to 0, so if 0 we do nothing if ( local_var.token != "FUNCTION" @@ -119,6 +118,7 @@ def visit_FUNCTION(self, node): if local_var.type_ == self.TYPE(TYPE.string): if local_var.class_ == CLASS.const or local_var.token == "FUNCTION": continue + # Only if it's string we free it if local_var.class_ != CLASS.array: # Ok just free it if scope == SCOPE.local or (scope == SCOPE.parameter and not local_var.byref): diff --git a/src/arch/z80/visitor/translator.py b/src/arch/z80/visitor/translator.py index db2c1caea..3ffe1a1ca 100644 --- a/src/arch/z80/visitor/translator.py +++ b/src/arch/z80/visitor/translator.py @@ -25,7 +25,10 @@ from src.symbols.id_ import ref from src.symbols.type_ import Type -__all__ = ("Translator",) +__all__ = ( + "LabelledData", + "Translator", +) LabelledData = namedtuple("LabelledData", ("label", "data")) diff --git a/src/arch/z80/visitor/var_translator.py b/src/arch/z80/visitor/var_translator.py index ddc308fb7..276ecb190 100644 --- a/src/arch/z80/visitor/var_translator.py +++ b/src/arch/z80/visitor/var_translator.py @@ -46,11 +46,11 @@ def visit_ARRAYDECL(self, node): lbound_label = entry.mangled + ".__LBOUND__" ubound_label = entry.mangled + ".__UBOUND__" - - is_zero_based_array = all(bound.lower == 0 for bound in node.bounds) bound_ptrs = ["0", "0"] # NULL by default - if entry.lbound_used or not is_zero_based_array: + + if not entry.is_zero_based and entry.is_dynamically_accessed: bound_ptrs[0] = lbound_label + if entry.ubound_used or OPTIONS.array_check: bound_ptrs[1] = ubound_label diff --git a/src/lib/arch/zx48k/runtime/array/arrayalloc.asm b/src/lib/arch/zx48k/runtime/array/arrayalloc.asm index 7ec636788..04f593249 100644 --- a/src/lib/arch/zx48k/runtime/array/arrayalloc.asm +++ b/src/lib/arch/zx48k/runtime/array/arrayalloc.asm @@ -41,7 +41,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it -; with 0 bytes +; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -99,12 +99,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret diff --git a/src/lib/arch/zx48k/runtime/bound.asm b/src/lib/arch/zx48k/runtime/bound.asm index 7eb344b7e..6cb71eafa 100644 --- a/src/lib/arch/zx48k/runtime/bound.asm +++ b/src/lib/arch/zx48k/runtime/bound.asm @@ -70,6 +70,10 @@ __CONT: ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound + add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/src/lib/arch/zxnext/runtime/array/arrayalloc.asm b/src/lib/arch/zxnext/runtime/array/arrayalloc.asm index 7ec636788..04f593249 100644 --- a/src/lib/arch/zxnext/runtime/array/arrayalloc.asm +++ b/src/lib/arch/zxnext/runtime/array/arrayalloc.asm @@ -41,7 +41,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it -; with 0 bytes +; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -99,12 +99,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret diff --git a/src/symbols/arrayaccess.py b/src/symbols/arrayaccess.py index bf40ea01b..b743c6c4a 100644 --- a/src/symbols/arrayaccess.py +++ b/src/symbols/arrayaccess.py @@ -35,6 +35,7 @@ class SymbolARRAYACCESS(SymbolCALL): def __init__(self, entry, arglist: SymbolARGLIST, lineno: int, filename: str): super().__init__(entry, arglist, lineno, filename) assert all(gl.BOUND_TYPE == x.type_.type_ for x in arglist), "Invalid type for array index" + self.entry.ref.is_dynamically_accessed = True @property def entry(self): @@ -90,6 +91,12 @@ def offset(self) -> int | None: offset *= self.type_.size return offset + @cached_property + def is_constant(self) -> bool: + """Whether this array access is constant. + e.g. A(1) is constant. A(i) is not.""" + return self.offset is None + @classmethod def make_node(cls, id_: str, arglist: SymbolARGLIST, lineno: int, filename: str) -> Optional["SymbolARRAYACCESS"]: """Creates an array access. A(x1, x2, ..., xn)""" diff --git a/src/symbols/id_/_id.py b/src/symbols/id_/_id.py index ba9cea6f2..0fce2076c 100644 --- a/src/symbols/id_/_id.py +++ b/src/symbols/id_/_id.py @@ -40,11 +40,7 @@ class SymbolID(SymbolIdABC): "declared", "filename", "has_address", - "lineno", - "mangled", - "name", "original_name", - "scope", "scope_ref", ) diff --git a/src/symbols/id_/interface.py b/src/symbols/id_/interface.py index 0dcca50d2..85983c9ea 100644 --- a/src/symbols/id_/interface.py +++ b/src/symbols/id_/interface.py @@ -6,7 +6,7 @@ class SymbolIdABC(Symbol, ABC): - __slots__ = () + __slots__ = "lineno", "mangled", "name", "scope" scope: SCOPE name: str diff --git a/src/symbols/id_/ref/arrayref.py b/src/symbols/id_/ref/arrayref.py index 94afd5aaa..1d315ce59 100644 --- a/src/symbols/id_/ref/arrayref.py +++ b/src/symbols/id_/ref/arrayref.py @@ -8,7 +8,7 @@ class ArrayRef(VarRef): - __slots__ = "lbound_used", "ubound_used" + __slots__ = "is_dynamically_accessed", "lbound_used", "ubound_used" def __init__(self, parent: SymbolID, bounds: SymbolBOUNDLIST): super().__init__(parent) @@ -19,6 +19,7 @@ def __init__(self, parent: SymbolID, bounds: SymbolBOUNDLIST): self.callable = True self.offset: str | None = None self.byref = False # Whether this array is passed by ref to a func + self.is_dynamically_accessed: bool = False # Whether the array is accessed using variables at any moment @property def token(self) -> str: @@ -39,8 +40,16 @@ def size(self): @property def memsize(self): - """Total array cell + indexes size""" - return (2 + (2 if self.lbound_used or self.ubound_used else 0)) * TYPE.size(gl.PTR_TYPE) + """Total array cell + indexes size + The current implementation of an array is a struct with the following information: + + - PTR to DIM sizes table + - PTR to Array DATA region + - PTR to LBound Tables (always required; 0 for 0 based arrays) + - PTR to UBound Tables (always required, even if not used) + """ + ptr_size = TYPE.size(gl.PTR_TYPE) # Size of a pointer for the selected arch + return ptr_size * (3 + self.ubound_used) @property def data_label(self) -> str: @@ -62,10 +71,14 @@ def t(self): return "$" + self._t # Local string variables (and parameters) use '$' (see backend) @property - def bounds(self): + def bounds(self) -> SymbolBOUNDLIST: return self.parent.children[0] @bounds.setter def bounds(self, value: SymbolBOUNDLIST): assert isinstance(value, SymbolBOUNDLIST) self.parent.children = [value] + + @property + def is_zero_based(self) -> bool: + return all(bound.lower == 0 for bound in self.bounds) diff --git a/tests/functional/arch/zx48k/40.asm b/tests/functional/arch/zx48k/40.asm index 4dba6dde4..81a072002 100644 --- a/tests/functional/arch/zx48k/40.asm +++ b/tests/functional/arch/zx48k/40.asm @@ -46,9 +46,10 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 3 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -57,8 +58,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -70,8 +71,8 @@ _test__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -82,7 +83,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -142,7 +143,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -176,8 +177,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -284,7 +285,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -315,9 +316,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -382,7 +383,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -416,7 +417,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -452,7 +453,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -480,10 +481,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 47 "40.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 48 "arch/zx48k/40.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -641,9 +642,9 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 48 "40.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" +#line 49 "arch/zx48k/40.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/u32tofreg.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/neg32.asm" push namespace core __ABS32: bit 7, d @@ -668,7 +669,7 @@ __NEG32: ; Negates DEHL (Two's complement) inc de ret pop namespace -#line 2 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/u32tofreg.asm" push namespace core __I8TOFREG: ld l, a @@ -738,7 +739,7 @@ __U32TOFREG_END: ret ENDP pop namespace -#line 49 "40.bas" +#line 50 "arch/zx48k/40.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/42.asm b/tests/functional/arch/zx48k/42.asm index 526556c98..4163e75a4 100644 --- a/tests/functional/arch/zx48k/42.asm +++ b/tests/functional/arch/zx48k/42.asm @@ -46,22 +46,23 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 3 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl ld a, (hl) ld (ix+5), a _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -73,8 +74,8 @@ _test__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -85,7 +86,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -145,7 +146,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -179,8 +180,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -287,7 +288,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -318,9 +319,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -385,7 +386,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -419,7 +420,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -455,7 +456,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -483,10 +484,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 50 "42.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 51 "arch/zx48k/42.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -644,7 +645,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 51 "42.bas" +#line 52 "arch/zx48k/42.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/43.asm b/tests/functional/arch/zx48k/43.asm index 77162e42e..de3cb1dfa 100644 --- a/tests/functional/arch/zx48k/43.asm +++ b/tests/functional/arch/zx48k/43.asm @@ -46,16 +46,17 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 3 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY ld a, (ix+5) push af - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl pop af add a, (hl) @@ -63,8 +64,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -76,8 +77,8 @@ _test__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -88,7 +89,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -148,7 +149,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -182,8 +183,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -290,7 +291,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -321,9 +322,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -388,7 +389,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -422,7 +423,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -458,7 +459,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -486,10 +487,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 53 "43.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 54 "arch/zx48k/43.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -647,9 +648,9 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 54 "43.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" +#line 55 "arch/zx48k/43.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/u32tofreg.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/neg32.asm" push namespace core __ABS32: bit 7, d @@ -674,7 +675,7 @@ __NEG32: ; Negates DEHL (Two's complement) inc de ret pop namespace -#line 2 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/u32tofreg.asm" push namespace core __I8TOFREG: ld l, a @@ -744,7 +745,7 @@ __U32TOFREG_END: ret ENDP pop namespace -#line 55 "43.bas" +#line 56 "arch/zx48k/43.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/45.asm b/tests/functional/arch/zx48k/45.asm index b353cdc42..e8429cc3f 100644 --- a/tests/functional/arch/zx48k/45.asm +++ b/tests/functional/arch/zx48k/45.asm @@ -43,19 +43,23 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl - inc sp + ld hl, -7 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 6 + ld d, h + ld e, l + inc de + ldir ld hl, .LABEL.__LABEL1 push hl - ld hl, -5 + ld hl, -7 ld de, .LABEL.__LABEL0 ld bc, 12 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-3) - ld h, (ix-2) + ld l, (ix-5) + ld h, (ix-4) ld de, 7 add hl, de ld a, (hl) @@ -63,8 +67,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-3) - ld h, (ix-2) + ld l, (ix-5) + ld h, (ix-4) call .core.__MEM_FREE ex af, af' exx @@ -72,8 +76,8 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -84,7 +88,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -144,7 +148,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -178,8 +182,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -286,7 +290,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -317,9 +321,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -384,7 +388,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -418,7 +422,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -454,7 +458,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -482,10 +486,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 49 "45.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 53 "arch/zx48k/45.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -643,7 +647,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 50 "45.bas" +#line 54 "arch/zx48k/45.bas" .LABEL.__LABEL0: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/47.asm b/tests/functional/arch/zx48k/47.asm index 302486dfc..7fd67d70f 100644 --- a/tests/functional/arch/zx48k/47.asm +++ b/tests/functional/arch/zx48k/47.asm @@ -43,13 +43,18 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir ld hl, .LABEL.__LABEL1 push hl - ld hl, -6 + ld hl, -8 ld de, .LABEL.__LABEL0 ld bc, 12 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -65,7 +70,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY ld a, (hl) @@ -73,8 +78,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__MEM_FREE ex af, af' exx @@ -82,7 +87,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -143,8 +148,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -173,7 +178,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -201,7 +206,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -220,7 +225,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -228,7 +233,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -241,8 +246,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 59 "arch/zx48k/47.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 64 "arch/zx48k/47.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -588,7 +593,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -624,7 +629,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -652,9 +657,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 60 "arch/zx48k/47.bas" +#line 65 "arch/zx48k/47.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -813,7 +818,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 61 "arch/zx48k/47.bas" +#line 66 "arch/zx48k/47.bas" .LABEL.__LABEL0: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/arr_addr_local.asm b/tests/functional/arch/zx48k/arr_addr_local.asm index 215a3a81a..6d749c714 100644 --- a/tests/functional/arch/zx48k/arr_addr_local.asm +++ b/tests/functional/arch/zx48k/arr_addr_local.asm @@ -47,9 +47,10 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 9 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -59,7 +60,7 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY push hl @@ -69,8 +70,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -78,7 +79,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -139,8 +140,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -169,7 +170,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -197,7 +198,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -216,7 +217,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -224,7 +225,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -237,8 +238,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 55 "arch/zx48k/arr_addr_local.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 56 "arch/zx48k/arr_addr_local.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -584,7 +585,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -620,7 +621,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -648,9 +649,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 56 "arch/zx48k/arr_addr_local.bas" +#line 57 "arch/zx48k/arr_addr_local.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -809,7 +810,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 57 "arch/zx48k/arr_addr_local.bas" +#line 58 "arch/zx48k/arr_addr_local.bas" .LABEL.__LABEL0: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/arraycopy1.asm b/tests/functional/arch/zx48k/arraycopy1.asm index f1aa26eac..42b94e82b 100644 --- a/tests/functional/arch/zx48k/arraycopy1.asm +++ b/tests/functional/arch/zx48k/arraycopy1.asm @@ -61,12 +61,13 @@ _Test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 5 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 5 ld b, h @@ -77,8 +78,8 @@ _Test: _Test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -86,7 +87,7 @@ _Test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -432,7 +433,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -468,7 +469,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -496,9 +497,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 48 "arch/zx48k/arraycopy1.bas" +#line 49 "arch/zx48k/arraycopy1.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -657,7 +658,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 49 "arch/zx48k/arraycopy1.bas" +#line 50 "arch/zx48k/arraycopy1.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arraycopy2.asm b/tests/functional/arch/zx48k/arraycopy2.asm index ddf16ae88..4f03dcca1 100644 --- a/tests/functional/arch/zx48k/arraycopy2.asm +++ b/tests/functional/arch/zx48k/arraycopy2.asm @@ -61,14 +61,15 @@ _Test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 5 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 5 ld b, h @@ -79,8 +80,8 @@ _Test: _Test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -88,7 +89,7 @@ _Test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -434,7 +435,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -470,7 +471,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -498,9 +499,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 50 "arch/zx48k/arraycopy2.bas" +#line 51 "arch/zx48k/arraycopy2.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -659,7 +660,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 51 "arch/zx48k/arraycopy2.bas" +#line 52 "arch/zx48k/arraycopy2.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arraycopy3.asm b/tests/functional/arch/zx48k/arraycopy3.asm index a3518e57c..8f12cc7b2 100644 --- a/tests/functional/arch/zx48k/arraycopy3.asm +++ b/tests/functional/arch/zx48k/arraycopy3.asm @@ -43,30 +43,30 @@ _Test: push ix ld ix, 0 add ix, sp - ld hl, -8 + ld hl, -12 add hl, sp ld sp, hl ld (hl), 0 - ld bc, 7 + ld bc, 11 ld d, h ld e, l inc de ldir ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 5 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld hl, -8 + ld hl, -12 ld de, .LABEL.__LABEL2 ld bc, 5 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 5 ld b, h @@ -77,11 +77,11 @@ _Test: _Test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) call .core.__MEM_FREE ex af, af' exx @@ -89,8 +89,8 @@ _Test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -101,7 +101,7 @@ _Test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -161,7 +161,7 @@ _Test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -195,8 +195,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -303,7 +303,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -334,9 +334,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -401,7 +401,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -435,7 +435,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -471,7 +471,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -499,10 +499,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 66 "arraycopy3.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 66 "arch/zx48k/arraycopy3.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -660,7 +660,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 67 "arraycopy3.bas" +#line 67 "arch/zx48k/arraycopy3.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arraycopy4.asm b/tests/functional/arch/zx48k/arraycopy4.asm index eba73e069..89b95e7aa 100644 --- a/tests/functional/arch/zx48k/arraycopy4.asm +++ b/tests/functional/arch/zx48k/arraycopy4.asm @@ -44,28 +44,28 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, -8 + ld hl, -12 add hl, sp ld sp, hl ld (hl), 0 - ld bc, 7 + ld bc, 11 ld d, h ld e, l inc de ldir - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 22 call .core.__ALLOC_LOCAL_ARRAY - ld hl, -8 + ld hl, -12 ld de, .LABEL.__LABEL1 ld bc, 22 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 11 push hl @@ -75,13 +75,13 @@ _test__leave: exx ld hl, 11 push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__ARRAYSTR_FREE_MEM ld hl, 11 push hl - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -89,8 +89,8 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -101,7 +101,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -161,7 +161,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -195,8 +195,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -303,7 +303,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -334,9 +334,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -401,7 +401,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -435,7 +435,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -471,7 +471,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -499,14 +499,14 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 66 "zx48k/arraycopy4.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arraystrfree.asm" +#line 66 "arch/zx48k/arraycopy4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -664,7 +664,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/arch/zx48k/library-asm/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -706,8 +706,8 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 67 "zx48k/arraycopy4.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/strarraycpy.asm" +#line 67 "arch/zx48k/arraycopy4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/strarraycpy.asm" ; (K)opyleft - by Jose M. Rodriguez de la Rosa (a.k.a. Boriel) ; 2009 - This is Free OpenSource BSD code ; vim: et:ts=4:sw=4 @@ -715,7 +715,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself ; reallocating strings of the destiny vector to hold source strings. ; This is used in the following code: ; DIM a$(20) : DIM b$(20): a$ = b$ -#line 1 "/zxbasic/src/arch/zx48k/library-asm/lddede.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/lddede.asm" ; Loads DE into DE ; Modifies C register ; There is a routine similar to this one @@ -730,9 +730,9 @@ __LOAD_DE_DE: ex de, hl ret pop namespace -#line 11 "/zxbasic/src/arch/zx48k/library-asm/strarraycpy.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/strcpy.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/realloc.asm" +#line 11 "/zxbasic/src/lib/arch/zx48k/runtime/array/strarraycpy.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/strcpy.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/realloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -862,7 +862,7 @@ __REALLOC_END: ret ENDP pop namespace -#line 2 "/zxbasic/src/arch/zx48k/library-asm/strcpy.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/strcpy.asm" ; String library push namespace core __STRASSIGN: ; Performs a$ = b$ (HL = address of a$; DE = Address of b$) @@ -941,7 +941,7 @@ __NOTHING_TO_COPY: ret ENDP pop namespace -#line 12 "/zxbasic/src/arch/zx48k/library-asm/strarraycpy.asm" +#line 12 "/zxbasic/src/lib/arch/zx48k/runtime/array/strarraycpy.asm" push namespace core STR_ARRAYCOPY: ; Copies an array of string a$ = b$ @@ -987,7 +987,7 @@ LOOP: jp LOOP ENDP pop namespace -#line 68 "zx48k/arraycopy4.bas" +#line 68 "arch/zx48k/arraycopy4.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arrlabels1.asm b/tests/functional/arch/zx48k/arrlabels1.asm index 0f9daa154..a64dc1fa2 100644 --- a/tests/functional/arch/zx48k/arrlabels1.asm +++ b/tests/functional/arch/zx48k/arrlabels1.asm @@ -22,7 +22,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFW _a.__DATA__ @@ -31,8 +31,6 @@ _a.__DATA__: .LABEL.__LABEL0: DEFW 0000h DEFB 02h -_a.__LBOUND__: - DEFW 0001h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 0 diff --git a/tests/functional/arch/zx48k/arrlabels10a.asm b/tests/functional/arch/zx48k/arrlabels10a.asm index 104571c3a..4fbd47da6 100644 --- a/tests/functional/arch/zx48k/arrlabels10a.asm +++ b/tests/functional/arch/zx48k/arrlabels10a.asm @@ -22,7 +22,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB (_a.__DATA__) & 0xFF @@ -31,8 +31,6 @@ _a.__DATA__: .LABEL.__LABEL0: DEFW 0000h DEFB 01h -_a.__LBOUND__: - DEFW 0001h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 0 diff --git a/tests/functional/arch/zx48k/arrlabels10b.asm b/tests/functional/arch/zx48k/arrlabels10b.asm index d7d3610dc..88e4644c4 100644 --- a/tests/functional/arch/zx48k/arrlabels10b.asm +++ b/tests/functional/arch/zx48k/arrlabels10b.asm @@ -22,7 +22,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFW 0000h @@ -36,8 +36,6 @@ _a.__DATA__: .LABEL.__LABEL0: DEFW 0000h DEFB 04h -_a.__LBOUND__: - DEFW 0001h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 0 diff --git a/tests/functional/arch/zx48k/arrlabels4.asm b/tests/functional/arch/zx48k/arrlabels4.asm index 2cfc2183a..6193ba4dc 100644 --- a/tests/functional/arch/zx48k/arrlabels4.asm +++ b/tests/functional/arch/zx48k/arrlabels4.asm @@ -50,14 +50,19 @@ _test: ld hl, 0 push hl push hl + push hl + ld hl, 0 + push hl + ld hl, _test.a.__LBOUND__ + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 - call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ld l, (ix-4) + ld h, (ix-3) ld a, (hl) inc hl ld h, (hl) @@ -69,17 +74,19 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret +_test.a.__LBOUND__: + DEFW 0001h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -90,7 +97,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -150,7 +157,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -184,8 +191,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -292,7 +299,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -323,9 +330,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -390,7 +397,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -424,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -460,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -488,10 +495,70 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" + ; --------------------------------------------------------------------- + ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes. Then sets LBOUND and UBOUND ptrs + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; [SP + 2] PTR to the lbound element area + ; [SP + 4] PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: + call __ALLOC_LOCAL_ARRAY +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: + pop bc ;; ret address + pop de ;; lbound + inc hl + ld (hl), e + inc hl + ld (hl), d + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used + inc hl + ld (hl), e + inc hl + ld (hl), d + ret + ; --------------------------------------------------------------------- + ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; TOP of the stack = PTR to the element area + ; [SP + 2] = PTR to the element area + ; [SP + 4] = PTR to the lbound element area + ; [SP + 6] = PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: + ;; Swaps [SP] and [SP + 2] + exx + pop hl ;; Ret address + ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address + push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address + exx + call __ALLOC_INITIALIZED_LOCAL_ARRAY + jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 55 "arrlabels4.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 62 "arch/zx48k/arrlabels4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -649,7 +716,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 56 "arrlabels4.bas" +#line 63 "arch/zx48k/arrlabels4.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arrlabels5.asm b/tests/functional/arch/zx48k/arrlabels5.asm index c5ff4519c..a381d8c3e 100644 --- a/tests/functional/arch/zx48k/arrlabels5.asm +++ b/tests/functional/arch/zx48k/arrlabels5.asm @@ -47,17 +47,22 @@ _test: ld hl, 0 push hl push hl + push hl + ld hl, 0 + push hl + ld hl, _test.a.__LBOUND__ + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 - call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY + call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS .LABEL._label1: .LABEL._label2: .LABEL._label3: - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) ld a, (hl) inc hl ld h, (hl) @@ -69,17 +74,19 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret +_test.a.__LBOUND__: + DEFW 0001h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -90,7 +97,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -150,7 +157,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -184,8 +191,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -292,7 +299,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -323,9 +330,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -390,7 +397,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -424,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -460,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -488,10 +495,70 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" + ; --------------------------------------------------------------------- + ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes. Then sets LBOUND and UBOUND ptrs + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; [SP + 2] PTR to the lbound element area + ; [SP + 4] PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: + call __ALLOC_LOCAL_ARRAY +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: + pop bc ;; ret address + pop de ;; lbound + inc hl + ld (hl), e + inc hl + ld (hl), d + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used + inc hl + ld (hl), e + inc hl + ld (hl), d + ret + ; --------------------------------------------------------------------- + ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; TOP of the stack = PTR to the element area + ; [SP + 2] = PTR to the element area + ; [SP + 4] = PTR to the lbound element area + ; [SP + 6] = PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: + ;; Swaps [SP] and [SP + 2] + exx + pop hl ;; Ret address + ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address + push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address + exx + call __ALLOC_INITIALIZED_LOCAL_ARRAY + jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 55 "arrlabels5.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 62 "arch/zx48k/arrlabels5.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -649,7 +716,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 56 "arrlabels5.bas" +#line 63 "arch/zx48k/arrlabels5.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arrlabels7.asm b/tests/functional/arch/zx48k/arrlabels7.asm index 081a1d589..46f949ef3 100644 --- a/tests/functional/arch/zx48k/arrlabels7.asm +++ b/tests/functional/arch/zx48k/arrlabels7.asm @@ -47,14 +47,19 @@ _test: ld hl, 0 push hl push hl + push hl + ld hl, 0 + push hl + ld hl, _test.a.__LBOUND__ + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 - call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ld l, (ix-4) + ld h, (ix-3) ld a, (hl) inc hl ld h, (hl) @@ -69,17 +74,19 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret +_test.a.__LBOUND__: + DEFW 0001h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -90,7 +97,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -150,7 +157,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -184,8 +191,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -292,7 +299,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -323,9 +330,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -390,7 +397,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -424,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -460,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -488,10 +495,70 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" + ; --------------------------------------------------------------------- + ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes. Then sets LBOUND and UBOUND ptrs + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; [SP + 2] PTR to the lbound element area + ; [SP + 4] PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: + call __ALLOC_LOCAL_ARRAY +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: + pop bc ;; ret address + pop de ;; lbound + inc hl + ld (hl), e + inc hl + ld (hl), d + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used + inc hl + ld (hl), e + inc hl + ld (hl), d + ret + ; --------------------------------------------------------------------- + ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; TOP of the stack = PTR to the element area + ; [SP + 2] = PTR to the element area + ; [SP + 4] = PTR to the lbound element area + ; [SP + 6] = PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: + ;; Swaps [SP] and [SP + 2] + exx + pop hl ;; Ret address + ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address + push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address + exx + call __ALLOC_INITIALIZED_LOCAL_ARRAY + jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 55 "arrlabels7.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 62 "arch/zx48k/arrlabels7.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -649,7 +716,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 56 "arrlabels7.bas" +#line 63 "arch/zx48k/arrlabels7.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arrlabels8.asm b/tests/functional/arch/zx48k/arrlabels8.asm index 035ef9be4..1b701c0fe 100644 --- a/tests/functional/arch/zx48k/arrlabels8.asm +++ b/tests/functional/arch/zx48k/arrlabels8.asm @@ -50,14 +50,19 @@ _test: ld hl, 0 push hl push hl + push hl + ld hl, 0 + push hl + ld hl, _test.a.__LBOUND__ + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 - call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ld l, (ix-4) + ld h, (ix-3) ld a, (hl) inc hl ld h, (hl) @@ -69,17 +74,19 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret +_test.a.__LBOUND__: + DEFW 0001h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -90,7 +97,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -150,7 +157,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -184,8 +191,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -292,7 +299,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -323,9 +330,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -390,7 +397,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -424,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -460,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -488,10 +495,70 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" + ; --------------------------------------------------------------------- + ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes. Then sets LBOUND and UBOUND ptrs + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; [SP + 2] PTR to the lbound element area + ; [SP + 4] PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: + call __ALLOC_LOCAL_ARRAY +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: + pop bc ;; ret address + pop de ;; lbound + inc hl + ld (hl), e + inc hl + ld (hl), d + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used + inc hl + ld (hl), e + inc hl + ld (hl), d + ret + ; --------------------------------------------------------------------- + ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; TOP of the stack = PTR to the element area + ; [SP + 2] = PTR to the element area + ; [SP + 4] = PTR to the lbound element area + ; [SP + 6] = PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: + ;; Swaps [SP] and [SP + 2] + exx + pop hl ;; Ret address + ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address + push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address + exx + call __ALLOC_INITIALIZED_LOCAL_ARRAY + jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 55 "arrlabels8.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 62 "arch/zx48k/arrlabels8.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -649,7 +716,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 56 "arrlabels8.bas" +#line 63 "arch/zx48k/arrlabels8.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/arrlabels9.asm b/tests/functional/arch/zx48k/arrlabels9.asm index 7841d014f..3c2a60a61 100644 --- a/tests/functional/arch/zx48k/arrlabels9.asm +++ b/tests/functional/arch/zx48k/arrlabels9.asm @@ -50,14 +50,19 @@ _test: ld hl, 0 push hl push hl + push hl + ld hl, 0 + push hl + ld hl, _test.a.__LBOUND__ + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 - call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ld l, (ix-4) + ld h, (ix-3) ld a, (hl) inc hl ld h, (hl) @@ -69,17 +74,19 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret +_test.a.__LBOUND__: + DEFW 0001h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -90,7 +97,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -150,7 +157,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -184,8 +191,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -292,7 +299,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -323,9 +330,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -390,7 +397,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -424,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -460,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -488,10 +495,70 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" + ; --------------------------------------------------------------------- + ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes. Then sets LBOUND and UBOUND ptrs + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; [SP + 2] PTR to the lbound element area + ; [SP + 4] PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: + call __ALLOC_LOCAL_ARRAY +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: + pop bc ;; ret address + pop de ;; lbound + inc hl + ld (hl), e + inc hl + ld (hl), d + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used + inc hl + ld (hl), e + inc hl + ld (hl), d + ret + ; --------------------------------------------------------------------- + ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; TOP of the stack = PTR to the element area + ; [SP + 2] = PTR to the element area + ; [SP + 4] = PTR to the lbound element area + ; [SP + 6] = PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: + ;; Swaps [SP] and [SP + 2] + exx + pop hl ;; Ret address + ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address + push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address + exx + call __ALLOC_INITIALIZED_LOCAL_ARRAY + jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 55 "arrlabels9.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 62 "arch/zx48k/arrlabels9.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -649,7 +716,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 56 "arrlabels9.bas" +#line 63 "arch/zx48k/arrlabels9.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/bound00.asm b/tests/functional/arch/zx48k/bound00.asm index b8b4e9155..6e4b84a2a 100644 --- a/tests/functional/arch/zx48k/bound00.asm +++ b/tests/functional/arch/zx48k/bound00.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -46,8 +46,6 @@ _a.__DATA__: .LABEL.__LABEL0: DEFW 0000h DEFB 02h -_a.__LBOUND__: - DEFW 0002h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 1 diff --git a/tests/functional/arch/zx48k/bound01.asm b/tests/functional/arch/zx48k/bound01.asm index 14ccbeabc..edf30766c 100644 --- a/tests/functional/arch/zx48k/bound01.asm +++ b/tests/functional/arch/zx48k/bound01.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -89,9 +89,6 @@ _a.__DATA__: DEFW 0001h DEFW 0004h DEFB 02h -_a.__LBOUND__: - DEFW 0002h - DEFW 0003h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 8 diff --git a/tests/functional/arch/zx48k/bound02.asm b/tests/functional/arch/zx48k/bound02.asm index 86cdaf683..efc018770 100644 --- a/tests/functional/arch/zx48k/bound02.asm +++ b/tests/functional/arch/zx48k/bound02.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -89,9 +89,6 @@ _a.__DATA__: DEFW 0001h DEFW 0004h DEFB 02h -_a.__LBOUND__: - DEFW 0002h - DEFW 0003h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld a, 1 @@ -133,7 +130,7 @@ _a.__LBOUND__: ei ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -195,6 +192,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -207,5 +207,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 41 "bound02.bas" +#line 41 "arch/zx48k/bound02.bas" END diff --git a/tests/functional/arch/zx48k/bound03.asm b/tests/functional/arch/zx48k/bound03.asm index 1ba498eec..5e6ce5217 100644 --- a/tests/functional/arch/zx48k/bound03.asm +++ b/tests/functional/arch/zx48k/bound03.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -89,9 +89,6 @@ _a.__DATA__: DEFW 0001h DEFW 0004h DEFB 02h -_a.__LBOUND__: - DEFW 0002h - DEFW 0003h _a.__UBOUND__: DEFW 0008h DEFW 0006h @@ -198,6 +195,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/cast_f16_to_param.asm b/tests/functional/arch/zx48k/cast_f16_to_param.asm index e73cd249a..174f47600 100644 --- a/tests/functional/arch/zx48k/cast_f16_to_param.asm +++ b/tests/functional/arch/zx48k/cast_f16_to_param.asm @@ -49,12 +49,17 @@ _gfxDrawLineClip: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, 0 + push hl + ld hl, _gfxDrawLineClip.x.__LBOUND__ + push hl + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 8 - call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + call .core.__ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ld l, (ix-4) + ld h, (ix-3) call .core.__ILOAD32 ex de, hl ld (ix+4), l @@ -62,8 +67,8 @@ _gfxDrawLineClip: _gfxDrawLineClip__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -74,9 +79,11 @@ _gfxDrawLineClip__leave: ex (sp), hl exx ret +_gfxDrawLineClip.x.__LBOUND__: + DEFW 0001h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -87,7 +94,7 @@ _gfxDrawLineClip__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -147,7 +154,7 @@ _gfxDrawLineClip__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -181,8 +188,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -289,7 +296,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -320,9 +327,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -387,7 +394,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -421,7 +428,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -457,7 +464,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -485,10 +492,70 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" + ; --------------------------------------------------------------------- + ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes. Then sets LBOUND and UBOUND ptrs + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; [SP + 2] PTR to the lbound element area + ; [SP + 4] PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: + call __ALLOC_LOCAL_ARRAY +__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: + pop bc ;; ret address + pop de ;; lbound + inc hl + ld (hl), e + inc hl + ld (hl), d + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used + inc hl + ld (hl), e + inc hl + ld (hl), d + ret + ; --------------------------------------------------------------------- + ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS + ; Allocates an array element area in the heap, and clears it filling it + ; with 0 bytes + ; + ; Parameters + ; HL = Offset to be added to IX => HL = IX + HL + ; BC = Length of the element area = n.elements * size(element) + ; DE = PTR to the index table + ; TOP of the stack = PTR to the element area + ; [SP + 2] = PTR to the element area + ; [SP + 4] = PTR to the lbound element area + ; [SP + 6] = PTR to the ubound element area + ; +; Returns: + ; HL = (IX + HL) + 8 + ; --------------------------------------------------------------------- +__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: + ;; Swaps [SP] and [SP + 2] + exx + pop hl ;; Ret address + ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address + push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address + exx + call __ALLOC_INITIALIZED_LOCAL_ARRAY + jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 52 "cast_f16_to_param.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 59 "arch/zx48k/cast_f16_to_param.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -646,8 +713,8 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 53 "cast_f16_to_param.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" +#line 60 "arch/zx48k/cast_f16_to_param.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -665,7 +732,7 @@ __ILOAD32: ex de, hl ret pop namespace -#line 54 "cast_f16_to_param.bas" +#line 61 "arch/zx48k/cast_f16_to_param.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/lbound0.asm b/tests/functional/arch/zx48k/lbound0.asm index 854423613..438a58fcf 100644 --- a/tests/functional/arch/zx48k/lbound0.asm +++ b/tests/functional/arch/zx48k/lbound0.asm @@ -24,7 +24,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -40,9 +40,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 2 diff --git a/tests/functional/arch/zx48k/lbound1.asm b/tests/functional/arch/zx48k/lbound1.asm index 854423613..438a58fcf 100644 --- a/tests/functional/arch/zx48k/lbound1.asm +++ b/tests/functional/arch/zx48k/lbound1.asm @@ -24,7 +24,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -40,9 +40,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 2 diff --git a/tests/functional/arch/zx48k/lbound10.asm b/tests/functional/arch/zx48k/lbound10.asm index 53260ac24..f19dda1dc 100644 --- a/tests/functional/arch/zx48k/lbound10.asm +++ b/tests/functional/arch/zx48k/lbound10.asm @@ -81,46 +81,34 @@ _test3: push ix ld ix, 0 add ix, sp - ld hl, -8 - add hl, sp - ld sp, hl - ld (hl), 0 - ld bc, 7 - ld d, h - ld e, l - inc de - ldir ld hl, 0 push hl - ld hl, _test3.a.__LBOUND__ push hl - ld hl, -8 + push hl + ld hl, -6 ld de, .LABEL.__LABEL5 ld bc, 9 - call .core.__ALLOC_LOCAL_ARRAY_WITH_BOUNDS + call .core.__ALLOC_LOCAL_ARRAY push ix pop hl - ld de, -8 + ld de, -6 add hl, de push hl call _test1 _test3__leave: ex af, af' exx - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret -_test3.a.__LBOUND__: - DEFW 0003h - DEFW 0007h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -131,7 +119,7 @@ _test3.a.__LBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -191,7 +179,7 @@ _test3.a.__LBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -225,8 +213,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -333,7 +321,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -364,9 +352,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -431,7 +419,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -465,7 +453,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -501,7 +489,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -529,67 +517,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret - ; --------------------------------------------------------------------- - ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes. Then sets LBOUND and UBOUND ptrs - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; [SP + 2] PTR to the lbound element area - ; [SP + 4] PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: - call __ALLOC_LOCAL_ARRAY -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: - pop bc ;; ret address - pop de ;; lbound - inc hl - ld (hl), e - inc hl - ld (hl), d - pop de - inc hl - ld (hl), e - inc hl - ld (hl), d - push bc - ret - ; --------------------------------------------------------------------- - ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; TOP of the stack = PTR to the element area - ; [SP + 2] = PTR to the element area - ; [SP + 4] = PTR to the lbound element area - ; [SP + 6] = PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: - ;; Swaps [SP] and [SP + 2] - exx - pop hl ;; Ret address - ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address - push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address - exx - call __ALLOC_INITIALIZED_LOCAL_ARRAY - jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 92 "lbound10.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 80 "arch/zx48k/lbound10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -651,6 +582,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -663,8 +597,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 93 "lbound10.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 81 "arch/zx48k/lbound10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -822,7 +756,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 94 "lbound10.bas" +#line 82 "arch/zx48k/lbound10.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/lbound11.asm b/tests/functional/arch/zx48k/lbound11.asm index 27160db0f..e0dd42f5b 100644 --- a/tests/functional/arch/zx48k/lbound11.asm +++ b/tests/functional/arch/zx48k/lbound11.asm @@ -97,46 +97,34 @@ _test3: push ix ld ix, 0 add ix, sp - ld hl, -8 - add hl, sp - ld sp, hl - ld (hl), 0 - ld bc, 7 - ld d, h - ld e, l - inc de - ldir ld hl, 0 push hl - ld hl, _test3.a.__LBOUND__ push hl - ld hl, -8 + push hl + ld hl, -6 ld de, .LABEL.__LABEL5 ld bc, 9 - call .core.__ALLOC_LOCAL_ARRAY_WITH_BOUNDS + call .core.__ALLOC_LOCAL_ARRAY push ix pop hl - ld de, -8 + ld de, -6 add hl, de push hl call _test2 _test3__leave: ex af, af' exx - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret -_test3.a.__LBOUND__: - DEFW 0003h - DEFW 0007h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -147,7 +135,7 @@ _test3.a.__LBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -207,7 +195,7 @@ _test3.a.__LBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -241,8 +229,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -349,7 +337,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -380,9 +368,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -447,7 +435,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -481,7 +469,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -517,7 +505,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -545,67 +533,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret - ; --------------------------------------------------------------------- - ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes. Then sets LBOUND and UBOUND ptrs - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; [SP + 2] PTR to the lbound element area - ; [SP + 4] PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: - call __ALLOC_LOCAL_ARRAY -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: - pop bc ;; ret address - pop de ;; lbound - inc hl - ld (hl), e - inc hl - ld (hl), d - pop de - inc hl - ld (hl), e - inc hl - ld (hl), d - push bc - ret - ; --------------------------------------------------------------------- - ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; TOP of the stack = PTR to the element area - ; [SP + 2] = PTR to the element area - ; [SP + 4] = PTR to the lbound element area - ; [SP + 6] = PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: - ;; Swaps [SP] and [SP + 2] - exx - pop hl ;; Ret address - ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address - push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address - exx - call __ALLOC_INITIALIZED_LOCAL_ARRAY - jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 108 "lbound11.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 96 "arch/zx48k/lbound11.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -667,6 +598,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -679,8 +613,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 109 "lbound11.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 97 "arch/zx48k/lbound11.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -838,7 +772,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 110 "lbound11.bas" +#line 98 "arch/zx48k/lbound11.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/lbound12.asm b/tests/functional/arch/zx48k/lbound12.asm index 0b48295bb..1ebc7989b 100644 --- a/tests/functional/arch/zx48k/lbound12.asm +++ b/tests/functional/arch/zx48k/lbound12.asm @@ -81,26 +81,17 @@ _test1: push ix ld ix, 0 add ix, sp - ld hl, -8 - add hl, sp - ld sp, hl - ld (hl), 0 - ld bc, 7 - ld d, h - ld e, l - inc de - ldir ld hl, 0 push hl - ld hl, _test1.a1.__LBOUND__ push hl - ld hl, -8 + push hl + ld hl, -6 ld de, .LABEL.__LABEL5 ld bc, 18 - call .core.__ALLOC_LOCAL_ARRAY_WITH_BOUNDS + call .core.__ALLOC_LOCAL_ARRAY push ix pop hl - ld de, -8 + ld de, -6 add hl, de push hl call _test2 @@ -109,17 +100,14 @@ _test1__leave: exx ld hl, 9 push hl - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-4) + ld h, (ix-3) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx ld sp, ix pop ix ret -_test1.a1.__LBOUND__: - DEFW 0003h - DEFW 0007h _test2: push ix ld ix, 0 @@ -137,8 +125,8 @@ _test2__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -149,7 +137,7 @@ _test2__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -209,7 +197,7 @@ _test2__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -243,8 +231,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -351,7 +339,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -382,9 +370,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -449,7 +437,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -483,7 +471,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -519,7 +507,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -547,71 +535,14 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret - ; --------------------------------------------------------------------- - ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes. Then sets LBOUND and UBOUND ptrs - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; [SP + 2] PTR to the lbound element area - ; [SP + 4] PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: - call __ALLOC_LOCAL_ARRAY -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: - pop bc ;; ret address - pop de ;; lbound - inc hl - ld (hl), e - inc hl - ld (hl), d - pop de - inc hl - ld (hl), e - inc hl - ld (hl), d - push bc - ret - ; --------------------------------------------------------------------- - ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; TOP of the stack = PTR to the element area - ; [SP + 2] = PTR to the element area - ; [SP + 4] = PTR to the lbound element area - ; [SP + 6] = PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: - ;; Swaps [SP] and [SP + 2] - exx - pop hl ;; Ret address - ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address - push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address - exx - call __ALLOC_INITIALIZED_LOCAL_ARRAY - jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 110 "lbound12.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arraystrfree.asm" +#line 98 "arch/zx48k/lbound12.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -769,7 +700,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/arch/zx48k/library-asm/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -811,8 +742,8 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 111 "lbound12.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 99 "arch/zx48k/lbound12.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -874,6 +805,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -886,7 +820,7 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 112 "lbound12.bas" +#line 100 "arch/zx48k/lbound12.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/lbound13.asm b/tests/functional/arch/zx48k/lbound13.asm index 779acfadc..afea9981e 100644 --- a/tests/functional/arch/zx48k/lbound13.asm +++ b/tests/functional/arch/zx48k/lbound13.asm @@ -24,7 +24,7 @@ _x: DEFW .LABEL.__LABEL7 _x.__DATA__.__PTR__: DEFW _x.__DATA__ - DEFW _x.__LBOUND__ + DEFW 0 DEFW _x.__UBOUND__ _x.__DATA__: DEFB 01h @@ -35,8 +35,6 @@ _x.__DATA__: .LABEL.__LABEL7: DEFW 0000h DEFB 01h -_x.__LBOUND__: - DEFW 0000h _x.__UBOUND__: DEFW 0004h .core.ZXBASIC_USER_DATA_END: @@ -130,7 +128,7 @@ _maxValue__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -191,8 +189,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -221,7 +219,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -249,7 +247,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -268,7 +266,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -276,7 +274,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -352,6 +350,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/lbound2.asm b/tests/functional/arch/zx48k/lbound2.asm index 6314d5fb2..a130f7f99 100644 --- a/tests/functional/arch/zx48k/lbound2.asm +++ b/tests/functional/arch/zx48k/lbound2.asm @@ -27,7 +27,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -43,9 +43,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, (_b) @@ -68,7 +65,7 @@ _a.__LBOUND__: ei ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -130,6 +127,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -142,5 +142,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 22 "lbound2.bas" +#line 22 "arch/zx48k/lbound2.bas" END diff --git a/tests/functional/arch/zx48k/lbound3.asm b/tests/functional/arch/zx48k/lbound3.asm index 54641ca53..fb3e9b45b 100644 --- a/tests/functional/arch/zx48k/lbound3.asm +++ b/tests/functional/arch/zx48k/lbound3.asm @@ -24,7 +24,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -40,9 +40,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 3 diff --git a/tests/functional/arch/zx48k/lbound4.asm b/tests/functional/arch/zx48k/lbound4.asm index 64a7844db..e49070bf8 100644 --- a/tests/functional/arch/zx48k/lbound4.asm +++ b/tests/functional/arch/zx48k/lbound4.asm @@ -27,7 +27,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -43,9 +43,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, (_b) @@ -68,7 +65,7 @@ _a.__LBOUND__: ei ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -130,6 +127,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -142,5 +142,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 22 "lbound4.bas" +#line 22 "arch/zx48k/lbound4.bas" END diff --git a/tests/functional/arch/zx48k/lbound5.asm b/tests/functional/arch/zx48k/lbound5.asm index 9e2ce0850..dda9d7e7c 100644 --- a/tests/functional/arch/zx48k/lbound5.asm +++ b/tests/functional/arch/zx48k/lbound5.asm @@ -27,7 +27,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -43,9 +43,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, (_b) @@ -68,7 +65,7 @@ _a.__LBOUND__: ei ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -130,6 +127,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -142,5 +142,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 22 "lbound5.bas" +#line 22 "arch/zx48k/lbound5.bas" END diff --git a/tests/functional/arch/zx48k/lbound6.asm b/tests/functional/arch/zx48k/lbound6.asm index 6d049317f..6bc8425b6 100644 --- a/tests/functional/arch/zx48k/lbound6.asm +++ b/tests/functional/arch/zx48k/lbound6.asm @@ -48,23 +48,14 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, -8 - add hl, sp - ld sp, hl - ld (hl), 0 - ld bc, 7 - ld d, h - ld e, l - inc de - ldir ld hl, 0 push hl - ld hl, _test.a.__LBOUND__ push hl - ld hl, -8 + push hl + ld hl, -6 ld de, .LABEL.__LABEL5 ld bc, 9 - call .core.__ALLOC_LOCAL_ARRAY_WITH_BOUNDS + call .core.__ALLOC_LOCAL_ARRAY ld hl, 0 ld (_b), hl jp .LABEL.__LABEL0 @@ -73,7 +64,7 @@ _test: push hl push ix pop hl - ld de, -8 + ld de, -6 add hl, de call .core.__LBOUND ld (_c), hl @@ -91,20 +82,17 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx ld sp, ix pop ix ret -_test.a.__LBOUND__: - DEFW 0003h - DEFW 0007h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -115,7 +103,7 @@ _test.a.__LBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -175,7 +163,7 @@ _test.a.__LBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -209,8 +197,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -317,7 +305,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -348,9 +336,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -415,7 +403,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -449,7 +437,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -485,7 +473,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -513,67 +501,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret - ; --------------------------------------------------------------------- - ; __ALLOC_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes. Then sets LBOUND and UBOUND ptrs - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; [SP + 2] PTR to the lbound element area - ; [SP + 4] PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS: - call __ALLOC_LOCAL_ARRAY -__ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: - pop bc ;; ret address - pop de ;; lbound - inc hl - ld (hl), e - inc hl - ld (hl), d - pop de - inc hl - ld (hl), e - inc hl - ld (hl), d - push bc - ret - ; --------------------------------------------------------------------- - ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS - ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes - ; - ; Parameters - ; HL = Offset to be added to IX => HL = IX + HL - ; BC = Length of the element area = n.elements * size(element) - ; DE = PTR to the index table - ; TOP of the stack = PTR to the element area - ; [SP + 2] = PTR to the element area - ; [SP + 4] = PTR to the lbound element area - ; [SP + 6] = PTR to the ubound element area - ; -; Returns: - ; HL = (IX + HL) + 8 - ; --------------------------------------------------------------------- -__ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: - ;; Swaps [SP] and [SP + 2] - exx - pop hl ;; Ret address - ex (sp), hl ;; HL <- PTR to Element area, (sp) = Ret address - push hl ;; [SP] = PTR to element area, [SP + 2] = Ret address - exx - call __ALLOC_INITIALIZED_LOCAL_ARRAY - jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 76 "lbound6.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 64 "arch/zx48k/lbound6.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -635,6 +566,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -647,8 +581,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 77 "lbound6.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 65 "arch/zx48k/lbound6.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -806,7 +740,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 78 "lbound6.bas" +#line 66 "arch/zx48k/lbound6.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/lbound7.asm b/tests/functional/arch/zx48k/lbound7.asm index 311e59cbd..a23425f04 100644 --- a/tests/functional/arch/zx48k/lbound7.asm +++ b/tests/functional/arch/zx48k/lbound7.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL5 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -42,9 +42,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, _a @@ -103,7 +100,7 @@ _test__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -165,6 +162,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -177,5 +177,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 58 "lbound7.bas" +#line 58 "arch/zx48k/lbound7.bas" END diff --git a/tests/functional/arch/zx48k/lbound8.asm b/tests/functional/arch/zx48k/lbound8.asm index da22582f7..4234474aa 100644 --- a/tests/functional/arch/zx48k/lbound8.asm +++ b/tests/functional/arch/zx48k/lbound8.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL5 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -42,9 +42,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, _a @@ -98,7 +95,7 @@ _test__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -160,6 +157,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -172,5 +172,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 53 "lbound8.bas" +#line 53 "arch/zx48k/lbound8.bas" END diff --git a/tests/functional/arch/zx48k/lbound9.asm b/tests/functional/arch/zx48k/lbound9.asm index 57ead2e1d..b5c6fe479 100644 --- a/tests/functional/arch/zx48k/lbound9.asm +++ b/tests/functional/arch/zx48k/lbound9.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL5 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -42,9 +42,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, _a @@ -114,7 +111,7 @@ _test1__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -176,6 +173,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -188,5 +188,5 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 69 "lbound9.bas" +#line 69 "arch/zx48k/lbound9.bas" END diff --git a/tests/functional/arch/zx48k/lcd6.asm b/tests/functional/arch/zx48k/lcd6.asm index 21281ff2f..60da02e78 100644 --- a/tests/functional/arch/zx48k/lcd6.asm +++ b/tests/functional/arch/zx48k/lcd6.asm @@ -92,15 +92,16 @@ _SubLifetime: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 18 call .core.__ALLOC_LOCAL_ARRAY _SubLifetime__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -114,7 +115,7 @@ _SubLifetime__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -460,7 +461,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -496,7 +497,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -524,9 +525,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 45 "arch/zx48k/lcd6.bas" +#line 46 "arch/zx48k/lcd6.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -685,7 +686,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 46 "arch/zx48k/lcd6.bas" +#line 47 "arch/zx48k/lcd6.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/let_array_local_const0.asm b/tests/functional/arch/zx48k/let_array_local_const0.asm index 836f21b93..2ba0cb310 100644 --- a/tests/functional/arch/zx48k/let_array_local_const0.asm +++ b/tests/functional/arch/zx48k/let_array_local_const0.asm @@ -66,20 +66,21 @@ _test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL5 ld bc, 5 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl inc hl push hl ld a, (_downCellValue) pop hl ld (hl), a - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl inc hl inc hl @@ -95,7 +96,7 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY ld a, (hl) @@ -111,15 +112,15 @@ _test: sbc hl, de jp nc, .LABEL.__LABEL3 .LABEL.__LABEL2: - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) ld a, (hl) ld (0), a _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -127,7 +128,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -188,8 +189,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -218,7 +219,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -246,7 +247,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -265,7 +266,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -273,7 +274,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -286,8 +287,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 93 "arch/zx48k/let_array_local_const0.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 94 "arch/zx48k/let_array_local_const0.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -633,7 +634,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -669,7 +670,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -697,9 +698,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 94 "arch/zx48k/let_array_local_const0.bas" +#line 95 "arch/zx48k/let_array_local_const0.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -858,7 +859,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 95 "arch/zx48k/let_array_local_const0.bas" +#line 96 "arch/zx48k/let_array_local_const0.bas" .LABEL.__LABEL5: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_array_with_bounds0.asm b/tests/functional/arch/zx48k/local_array_with_bounds0.asm index 1f8132f1e..17644f76d 100644 --- a/tests/functional/arch/zx48k/local_array_with_bounds0.asm +++ b/tests/functional/arch/zx48k/local_array_with_bounds0.asm @@ -55,7 +55,7 @@ _test: ldir ld hl, _test.a.__UBOUND__ push hl - ld hl, _test.a.__LBOUND__ + ld hl, 0 push hl ld hl, .LABEL.__LABEL1 push hl @@ -97,13 +97,11 @@ _test__leave: ld sp, ix pop ix ret -_test.a.__LBOUND__: - DEFW 0000h _test.a.__UBOUND__: DEFW 0002h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -114,7 +112,7 @@ _test.a.__UBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -174,7 +172,7 @@ _test.a.__UBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -208,8 +206,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -316,7 +314,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -347,9 +345,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -414,7 +412,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -448,7 +446,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -484,7 +482,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -536,12 +534,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS @@ -569,10 +570,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: exx call __ALLOC_INITIALIZED_LOCAL_ARRAY jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 79 "local_array_with_bounds0.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 77 "arch/zx48k/local_array_with_bounds0.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -634,6 +635,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -646,8 +650,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 80 "local_array_with_bounds0.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 78 "arch/zx48k/local_array_with_bounds0.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -805,7 +809,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 81 "local_array_with_bounds0.bas" +#line 79 "arch/zx48k/local_array_with_bounds0.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_array_with_bounds1.asm b/tests/functional/arch/zx48k/local_array_with_bounds1.asm index 4a1a14822..e46799939 100644 --- a/tests/functional/arch/zx48k/local_array_with_bounds1.asm +++ b/tests/functional/arch/zx48k/local_array_with_bounds1.asm @@ -55,7 +55,7 @@ _test: ldir ld hl, _test.a.__UBOUND__ push hl - ld hl, _test.a.__LBOUND__ + ld hl, 0 push hl ld hl, -9 ld de, .LABEL.__LABEL0 @@ -95,13 +95,11 @@ _test__leave: ld sp, ix pop ix ret -_test.a.__LBOUND__: - DEFW 0000h _test.a.__UBOUND__: DEFW 0002h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -112,7 +110,7 @@ _test.a.__UBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -172,7 +170,7 @@ _test.a.__UBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -206,8 +204,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -314,7 +312,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -345,9 +343,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -412,7 +410,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -446,7 +444,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -482,7 +480,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -534,12 +532,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS @@ -567,10 +568,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: exx call __ALLOC_INITIALIZED_LOCAL_ARRAY jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 77 "local_array_with_bounds1.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 75 "arch/zx48k/local_array_with_bounds1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -632,6 +633,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -644,8 +648,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 78 "local_array_with_bounds1.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 76 "arch/zx48k/local_array_with_bounds1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -803,7 +807,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 79 "local_array_with_bounds1.bas" +#line 77 "arch/zx48k/local_array_with_bounds1.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_float_array0.asm b/tests/functional/arch/zx48k/local_float_array0.asm index ffb41e8bc..3ea077d48 100644 --- a/tests/functional/arch/zx48k/local_float_array0.asm +++ b/tests/functional/arch/zx48k/local_float_array0.asm @@ -48,13 +48,18 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir ld hl, .LABEL.__LABEL1 push hl - ld hl, -6 + ld hl, -8 ld de, .LABEL.__LABEL0 ld bc, 20 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -71,15 +76,15 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY call .core.__LOADF _test__leave: ex af, af' exx - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__MEM_FREE ex af, af' exx @@ -87,7 +92,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -148,8 +153,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -178,7 +183,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -206,7 +211,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -225,7 +230,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -233,7 +238,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -246,8 +251,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 62 "arch/zx48k/local_float_array0.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 67 "arch/zx48k/local_float_array0.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -593,7 +598,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -629,7 +634,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -657,9 +662,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 63 "arch/zx48k/local_float_array0.bas" +#line 68 "arch/zx48k/local_float_array0.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -818,7 +823,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 64 "arch/zx48k/local_float_array0.bas" +#line 69 "arch/zx48k/local_float_array0.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB @@ -846,7 +851,7 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL ld b, (hl) ret pop namespace -#line 65 "arch/zx48k/local_float_array0.bas" +#line 70 "arch/zx48k/local_float_array0.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -875,7 +880,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 66 "arch/zx48k/local_float_array0.bas" +#line 71 "arch/zx48k/local_float_array0.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_float_array1.asm b/tests/functional/arch/zx48k/local_float_array1.asm index 4b27d364b..9480b8940 100644 --- a/tests/functional/arch/zx48k/local_float_array1.asm +++ b/tests/functional/arch/zx48k/local_float_array1.asm @@ -51,22 +51,23 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 20 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) ld de, 5 add hl, de call .core.__LOADF _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -74,8 +75,8 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -86,7 +87,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -146,7 +147,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -180,8 +181,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -288,7 +289,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -319,9 +320,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -386,7 +387,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -420,7 +421,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -456,7 +457,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -484,10 +485,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 49 "zx48k/local_float_array1.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 50 "arch/zx48k/local_float_array1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -645,8 +646,8 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 50 "zx48k/local_float_array1.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" +#line 51 "arch/zx48k/local_float_array1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -673,8 +674,8 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL ld b, (hl) ret pop namespace -#line 51 "zx48k/local_float_array1.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" +#line 52 "arch/zx48k/local_float_array1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de @@ -702,7 +703,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 52 "zx48k/local_float_array1.bas" +#line 53 "arch/zx48k/local_float_array1.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_str_array0.asm b/tests/functional/arch/zx48k/local_str_array0.asm index ecfaa4482..b05f3ccf8 100644 --- a/tests/functional/arch/zx48k/local_str_array0.asm +++ b/tests/functional/arch/zx48k/local_str_array0.asm @@ -48,20 +48,21 @@ _test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL1 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl inc hl push hl ld de, .LABEL.__LABEL0 pop hl call .core.__STORE_STR - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl inc hl ld c, (hl) @@ -74,8 +75,8 @@ _test__leave: exx ld hl, 4 push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -96,7 +97,7 @@ _test__leave: DEFB 4Ch DEFB 44h ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -442,7 +443,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -478,7 +479,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -506,10 +507,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 73 "arch/zx48k/local_str_array0.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 74 "arch/zx48k/local_str_array0.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array @@ -671,7 +672,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -713,7 +714,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 74 "arch/zx48k/local_str_array0.bas" +#line 75 "arch/zx48k/local_str_array0.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again @@ -751,7 +752,7 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret pop namespace -#line 76 "arch/zx48k/local_str_array0.bas" +#line 77 "arch/zx48k/local_str_array0.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storestr.asm" ; vim:ts=4:et:sw=4 ; Stores value of current string pointed by DE register into address pointed by HL @@ -1000,7 +1001,7 @@ __STORE_STR: pop hl ; Returns ptr to b$ in HL (Caller might needed to free it from memory) ret pop namespace -#line 77 "arch/zx48k/local_str_array0.bas" +#line 78 "arch/zx48k/local_str_array0.bas" .LABEL.__LABEL1: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_str_array1.asm b/tests/functional/arch/zx48k/local_str_array1.asm index c053f155a..03baa8673 100644 --- a/tests/functional/arch/zx48k/local_str_array1.asm +++ b/tests/functional/arch/zx48k/local_str_array1.asm @@ -51,7 +51,8 @@ _test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL1 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY @@ -59,7 +60,7 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY pop de @@ -68,7 +69,7 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY call .core.__ILOADSTR @@ -77,8 +78,8 @@ _test__leave: exx ld hl, 4 push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -99,7 +100,7 @@ _test__leave: DEFB 4Ch DEFB 44h ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -160,8 +161,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -190,7 +191,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -218,7 +219,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -237,7 +238,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -245,7 +246,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -258,8 +259,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 73 "arch/zx48k/local_str_array1.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 74 "arch/zx48k/local_str_array1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -605,7 +606,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -641,7 +642,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -669,10 +670,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 74 "arch/zx48k/local_str_array1.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 75 "arch/zx48k/local_str_array1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array @@ -834,7 +835,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -876,7 +877,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 75 "arch/zx48k/local_str_array1.bas" +#line 76 "arch/zx48k/local_str_array1.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again @@ -914,7 +915,7 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret pop namespace -#line 77 "arch/zx48k/local_str_array1.bas" +#line 78 "arch/zx48k/local_str_array1.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storestr2.asm" ; Similar to __STORE_STR, but this one is called when ; the value of B$ if already duplicated onto the stack. @@ -948,7 +949,7 @@ __STORE_STR2: dec hl ; HL points to mem address variable. This might be useful in the future. ret pop namespace -#line 78 "arch/zx48k/local_str_array1.bas" +#line 79 "arch/zx48k/local_str_array1.bas" .LABEL.__LABEL1: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_str_array2.asm b/tests/functional/arch/zx48k/local_str_array2.asm index a796ce715..795b067d6 100644 --- a/tests/functional/arch/zx48k/local_str_array2.asm +++ b/tests/functional/arch/zx48k/local_str_array2.asm @@ -45,10 +45,15 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir push ix pop hl ld bc, -2 @@ -57,7 +62,7 @@ _test: ld hl, .LABEL.__LABEL1 ld bc, 2 ldir - ld hl, -6 + ld hl, -8 ld de, .LABEL.__LABEL2 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY @@ -66,7 +71,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY pop de @@ -76,7 +81,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY call .core.__ILOADSTR @@ -85,8 +90,8 @@ _test__leave: exx ld hl, 4 push hl - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -107,7 +112,7 @@ _test__leave: DEFB 4Ch DEFB 44h ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -168,8 +173,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -198,7 +203,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -226,7 +231,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -245,7 +250,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -253,7 +258,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -266,8 +271,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 84 "arch/zx48k/local_str_array2.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 89 "arch/zx48k/local_str_array2.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -613,7 +618,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -649,7 +654,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -677,10 +682,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 85 "arch/zx48k/local_str_array2.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 90 "arch/zx48k/local_str_array2.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array @@ -842,7 +847,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -884,7 +889,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 86 "arch/zx48k/local_str_array2.bas" +#line 91 "arch/zx48k/local_str_array2.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again @@ -922,7 +927,7 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret pop namespace -#line 88 "arch/zx48k/local_str_array2.bas" +#line 93 "arch/zx48k/local_str_array2.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storestr2.asm" ; Similar to __STORE_STR, but this one is called when ; the value of B$ if already duplicated onto the stack. @@ -956,7 +961,7 @@ __STORE_STR2: dec hl ; HL points to mem address variable. This might be useful in the future. ret pop namespace -#line 89 "arch/zx48k/local_str_array2.bas" +#line 94 "arch/zx48k/local_str_array2.bas" .LABEL.__LABEL1: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_str_array3.asm b/tests/functional/arch/zx48k/local_str_array3.asm index 39a2ea826..cc28ba333 100644 --- a/tests/functional/arch/zx48k/local_str_array3.asm +++ b/tests/functional/arch/zx48k/local_str_array3.asm @@ -47,11 +47,16 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl - ld hl, -6 + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir + ld hl, -8 ld de, .LABEL.__LABEL6 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY @@ -64,7 +69,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY pop de @@ -90,7 +95,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY call .core.__ILOADSTR @@ -99,8 +104,8 @@ _test__leave: exx ld hl, 4 push hl - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -126,7 +131,7 @@ _test__leave: DEFB 44h DEFB 20h ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -187,8 +192,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -217,7 +222,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -245,7 +250,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -264,7 +269,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -272,7 +277,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -285,8 +290,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 103 "arch/zx48k/local_str_array3.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 108 "arch/zx48k/local_str_array3.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -632,7 +637,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -668,7 +673,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -696,10 +701,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 104 "arch/zx48k/local_str_array3.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 109 "arch/zx48k/local_str_array3.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array @@ -861,7 +866,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -903,7 +908,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 105 "arch/zx48k/local_str_array3.bas" +#line 110 "arch/zx48k/local_str_array3.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again @@ -941,7 +946,7 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret pop namespace -#line 107 "arch/zx48k/local_str_array3.bas" +#line 112 "arch/zx48k/local_str_array3.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storestr2.asm" ; Similar to __STORE_STR, but this one is called when ; the value of B$ if already duplicated onto the stack. @@ -975,7 +980,7 @@ __STORE_STR2: dec hl ; HL points to mem address variable. This might be useful in the future. ret pop namespace -#line 108 "arch/zx48k/local_str_array3.bas" +#line 113 "arch/zx48k/local_str_array3.bas" .LABEL.__LABEL6: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_u16_array0.asm b/tests/functional/arch/zx48k/local_u16_array0.asm index 8c03fd6bd..4c7030443 100644 --- a/tests/functional/arch/zx48k/local_u16_array0.asm +++ b/tests/functional/arch/zx48k/local_u16_array0.asm @@ -47,14 +47,15 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 8 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) ld de, 6 add hl, de push hl @@ -64,8 +65,8 @@ _test: ld (hl), e inc hl ld (hl), d - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) ld de, 6 add hl, de ld a, (hl) @@ -75,8 +76,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -84,8 +85,8 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -96,7 +97,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -156,7 +157,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -190,8 +191,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -298,7 +299,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -329,9 +330,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -396,7 +397,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -430,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -466,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -494,10 +495,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 61 "local_u16_array0.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 62 "arch/zx48k/local_u16_array0.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -655,7 +656,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 62 "local_u16_array0.bas" +#line 63 "arch/zx48k/local_u16_array0.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_u16_array1.asm b/tests/functional/arch/zx48k/local_u16_array1.asm index 562872e42..b14c44763 100644 --- a/tests/functional/arch/zx48k/local_u16_array1.asm +++ b/tests/functional/arch/zx48k/local_u16_array1.asm @@ -50,7 +50,8 @@ _test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY @@ -58,7 +59,7 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY ld de, 3 @@ -69,7 +70,7 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY ld e, (hl) @@ -79,8 +80,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -88,7 +89,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -149,8 +150,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -179,7 +180,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -207,7 +208,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -226,7 +227,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -234,7 +235,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -247,8 +248,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 62 "arch/zx48k/local_u16_array1.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 63 "arch/zx48k/local_u16_array1.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -594,7 +595,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -630,7 +631,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -658,9 +659,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 63 "arch/zx48k/local_u16_array1.bas" +#line 64 "arch/zx48k/local_u16_array1.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -819,7 +820,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 64 "arch/zx48k/local_u16_array1.bas" +#line 65 "arch/zx48k/local_u16_array1.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_u16_array2.asm b/tests/functional/arch/zx48k/local_u16_array2.asm index f1af6674b..3dad2b874 100644 --- a/tests/functional/arch/zx48k/local_u16_array2.asm +++ b/tests/functional/arch/zx48k/local_u16_array2.asm @@ -44,10 +44,15 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir push ix pop hl ld bc, -2 @@ -56,7 +61,7 @@ _test: ld hl, .LABEL.__LABEL0 ld bc, 2 ldir - ld hl, -6 + ld hl, -8 ld de, .LABEL.__LABEL1 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY @@ -65,7 +70,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY ld de, 3 @@ -77,7 +82,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY ld e, (hl) @@ -87,8 +92,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__MEM_FREE ex af, af' exx @@ -96,7 +101,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -157,8 +162,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -187,7 +192,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -215,7 +220,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -234,7 +239,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -242,7 +247,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -255,8 +260,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 73 "arch/zx48k/local_u16_array2.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 78 "arch/zx48k/local_u16_array2.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -602,7 +607,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -638,7 +643,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -666,9 +671,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 74 "arch/zx48k/local_u16_array2.bas" +#line 79 "arch/zx48k/local_u16_array2.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -827,7 +832,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 75 "arch/zx48k/local_u16_array2.bas" +#line 80 "arch/zx48k/local_u16_array2.bas" .LABEL.__LABEL0: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/local_u16_array3.asm b/tests/functional/arch/zx48k/local_u16_array3.asm index edea29ebb..8e07d5651 100644 --- a/tests/functional/arch/zx48k/local_u16_array3.asm +++ b/tests/functional/arch/zx48k/local_u16_array3.asm @@ -46,11 +46,16 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl - ld hl, -6 + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir + ld hl, -8 ld de, .LABEL.__LABEL5 ld bc, 8 call .core.__ALLOC_LOCAL_ARRAY @@ -67,7 +72,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY pop de @@ -95,7 +100,7 @@ _test: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY ld e, (hl) @@ -105,8 +110,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__MEM_FREE ex af, af' exx @@ -118,7 +123,7 @@ _test__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -179,8 +184,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -209,7 +214,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -237,7 +242,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -256,7 +261,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -264,7 +269,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -277,8 +282,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 95 "arch/zx48k/local_u16_array3.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 100 "arch/zx48k/local_u16_array3.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -624,7 +629,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -660,7 +665,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -688,9 +693,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 96 "arch/zx48k/local_u16_array3.bas" +#line 101 "arch/zx48k/local_u16_array3.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -849,7 +854,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 97 "arch/zx48k/local_u16_array3.bas" +#line 102 "arch/zx48k/local_u16_array3.bas" .LABEL.__LABEL5: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/ltee10.asm b/tests/functional/arch/zx48k/ltee10.asm index 5adfc1109..a7f1ad571 100644 --- a/tests/functional/arch/zx48k/ltee10.asm +++ b/tests/functional/arch/zx48k/ltee10.asm @@ -48,9 +48,10 @@ _setlocal: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 3 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -60,15 +61,15 @@ _setlocal: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY ld (hl), 3 _setlocal__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -76,7 +77,7 @@ _setlocal__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -137,8 +138,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -167,7 +168,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -195,7 +196,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -214,7 +215,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -222,7 +223,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -235,8 +236,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 51 "arch/zx48k/ltee10.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 52 "arch/zx48k/ltee10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -582,7 +583,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -618,7 +619,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -646,9 +647,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 52 "arch/zx48k/ltee10.bas" +#line 53 "arch/zx48k/ltee10.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -807,7 +808,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 53 "arch/zx48k/ltee10.bas" +#line 54 "arch/zx48k/ltee10.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/ltee7.asm b/tests/functional/arch/zx48k/ltee7.asm index b3d856a04..22c06d4d9 100644 --- a/tests/functional/arch/zx48k/ltee7.asm +++ b/tests/functional/arch/zx48k/ltee7.asm @@ -48,7 +48,8 @@ _setlocal: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL1 ld bc, 12 call .core.__ALLOC_LOCAL_ARRAY @@ -58,7 +59,7 @@ _setlocal: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY pop de @@ -68,8 +69,8 @@ _setlocal__leave: exx ld hl, 6 push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -84,7 +85,7 @@ _setlocal__leave: DEFB 6Ch DEFB 6Fh ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -145,8 +146,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -175,7 +176,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -203,7 +204,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -222,7 +223,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -230,7 +231,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -243,8 +244,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 59 "arch/zx48k/ltee7.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 60 "arch/zx48k/ltee7.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -590,7 +591,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -626,7 +627,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -654,10 +655,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 60 "arch/zx48k/ltee7.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 61 "arch/zx48k/ltee7.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array @@ -819,7 +820,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -861,7 +862,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 61 "arch/zx48k/ltee7.bas" +#line 62 "arch/zx48k/ltee7.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storestr2.asm" ; Similar to __STORE_STR, but this one is called when ; the value of B$ if already duplicated onto the stack. @@ -895,7 +896,7 @@ __STORE_STR2: dec hl ; HL points to mem address variable. This might be useful in the future. ret pop namespace -#line 62 "arch/zx48k/ltee7.bas" +#line 63 "arch/zx48k/ltee7.bas" .LABEL.__LABEL1: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_at_copy2.asm b/tests/functional/arch/zx48k/opt1_dim_arr_at_copy2.asm index 0782edc6a..8b1f91c92 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_at_copy2.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_at_copy2.asm @@ -57,14 +57,15 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 16 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 16 ld b, h @@ -75,8 +76,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -84,7 +85,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -430,7 +431,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -466,7 +467,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -494,9 +495,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 51 "arch/zx48k/opt1_dim_arr_at_copy2.bas" +#line 52 "arch/zx48k/opt1_dim_arr_at_copy2.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -655,7 +656,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 52 "arch/zx48k/opt1_dim_arr_at_copy2.bas" +#line 53 "arch/zx48k/opt1_dim_arr_at_copy2.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_at_copy3.asm b/tests/functional/arch/zx48k/opt1_dim_arr_at_copy3.asm index 41d089b30..60d53479b 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_at_copy3.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_at_copy3.asm @@ -57,12 +57,13 @@ _test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 16 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 16 ld b, h @@ -73,8 +74,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -82,7 +83,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -428,7 +429,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -464,7 +465,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -492,9 +493,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 49 "arch/zx48k/opt1_dim_arr_at_copy3.bas" +#line 50 "arch/zx48k/opt1_dim_arr_at_copy3.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -653,7 +654,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 50 "arch/zx48k/opt1_dim_arr_at_copy3.bas" +#line 51 "arch/zx48k/opt1_dim_arr_at_copy3.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_at_copy4.asm b/tests/functional/arch/zx48k/opt1_dim_arr_at_copy4.asm index ed2393ec5..18e877937 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_at_copy4.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_at_copy4.asm @@ -44,28 +44,28 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, -8 + ld hl, -12 add hl, sp ld sp, hl ld (hl), 0 - ld bc, 7 + ld bc, 11 ld d, h ld e, l inc de ldir - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 16 call .core.__ALLOC_LOCAL_ARRAY - ld hl, -8 + ld hl, -12 ld de, .LABEL.__LABEL1 ld bc, 16 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 16 ld b, h @@ -76,11 +76,11 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) call .core.__MEM_FREE ex af, af' exx @@ -88,8 +88,8 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -100,7 +100,7 @@ _test__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -160,7 +160,7 @@ _test__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -194,8 +194,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -302,7 +302,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -333,9 +333,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -400,7 +400,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -434,7 +434,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -470,7 +470,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -498,10 +498,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 65 "opt1_dim_arr_at_copy4.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 65 "arch/zx48k/opt1_dim_arr_at_copy4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -659,7 +659,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 66 "opt1_dim_arr_at_copy4.bas" +#line 66 "arch/zx48k/opt1_dim_arr_at_copy4.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_local.asm b/tests/functional/arch/zx48k/opt1_dim_arr_local.asm index 75c053599..214df1700 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_local.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_local.asm @@ -49,9 +49,10 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -60,15 +61,15 @@ _test: push hl push ix pop hl - ld de, -4 + ld de, -6 add hl, de call .core.__ARRAY ld a, (hl) _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -76,7 +77,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -137,8 +138,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -167,7 +168,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -195,7 +196,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -214,7 +215,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -222,7 +223,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -235,8 +236,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 51 "arch/zx48k/opt1_dim_arr_local.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 52 "arch/zx48k/opt1_dim_arr_local.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -582,7 +583,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -618,7 +619,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -646,9 +647,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 52 "arch/zx48k/opt1_dim_arr_local.bas" +#line 53 "arch/zx48k/opt1_dim_arr_local.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -807,7 +808,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 53 "arch/zx48k/opt1_dim_arr_local.bas" +#line 54 "arch/zx48k/opt1_dim_arr_local.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_local2.asm b/tests/functional/arch/zx48k/opt1_dim_arr_local2.asm index 7738c136c..8a73fb9bf 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_local2.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_local2.asm @@ -47,14 +47,15 @@ _test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 6 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) inc hl inc hl inc hl @@ -63,8 +64,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -72,7 +73,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -418,7 +419,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -454,7 +455,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -482,9 +483,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 49 "arch/zx48k/opt1_dim_arr_local2.bas" +#line 50 "arch/zx48k/opt1_dim_arr_local2.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -643,7 +644,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 50 "arch/zx48k/opt1_dim_arr_local2.bas" +#line 51 "arch/zx48k/opt1_dim_arr_local2.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_local3.asm b/tests/functional/arch/zx48k/opt1_dim_arr_local3.asm index c7927676a..61a7bf23c 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_local3.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_local3.asm @@ -44,12 +44,16 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl - inc sp - ld hl, -5 + ld hl, -7 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 6 + ld d, h + ld e, l + inc de + ldir + ld hl, -7 ld de, .LABEL.__LABEL0 ld bc, 6 call .core.__ALLOC_LOCAL_ARRAY @@ -67,13 +71,13 @@ _test: push hl push ix pop hl - ld de, -5 + ld de, -7 add hl, de call .core.__ARRAY ld a, (hl) push af - ld l, (ix-3) - ld h, (ix-2) + ld l, (ix-5) + ld h, (ix-4) ld de, 4 add hl, de pop af @@ -81,8 +85,8 @@ _test: _test__leave: ex af, af' exx - ld l, (ix-3) - ld h, (ix-2) + ld l, (ix-5) + ld h, (ix-4) call .core.__MEM_FREE ex af, af' exx @@ -90,7 +94,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -151,8 +155,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -181,7 +185,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -209,7 +213,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -228,7 +232,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -236,7 +240,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -249,8 +253,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 67 "arch/zx48k/opt1_dim_arr_local3.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 71 "arch/zx48k/opt1_dim_arr_local3.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -596,7 +600,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -632,7 +636,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -660,9 +664,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 68 "arch/zx48k/opt1_dim_arr_local3.bas" +#line 72 "arch/zx48k/opt1_dim_arr_local3.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -821,7 +825,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 69 "arch/zx48k/opt1_dim_arr_local3.bas" +#line 73 "arch/zx48k/opt1_dim_arr_local3.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_local4.asm b/tests/functional/arch/zx48k/opt1_dim_arr_local4.asm index c323a39a3..974bc8f87 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_local4.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_local4.asm @@ -44,12 +44,16 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl - inc sp - ld hl, -5 + ld hl, -7 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 6 + ld d, h + ld e, l + inc de + ldir + ld hl, -7 ld de, .LABEL.__LABEL0 ld bc, 6 call .core.__ALLOC_LOCAL_ARRAY @@ -67,7 +71,7 @@ _test: push hl push ix pop hl - ld de, -5 + ld de, -7 add hl, de call .core.__ARRAY ld (hl), 7 @@ -77,15 +81,15 @@ _test: push hl push ix pop hl - ld de, -5 + ld de, -7 add hl, de call .core.__ARRAY ld a, (hl) _test__leave: ex af, af' exx - ld l, (ix-3) - ld h, (ix-2) + ld l, (ix-5) + ld h, (ix-4) call .core.__MEM_FREE ex af, af' exx @@ -93,7 +97,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -154,8 +158,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -184,7 +188,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -212,7 +216,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -231,7 +235,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -239,7 +243,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -252,8 +256,8 @@ ARRAY_SIZE_LOOP: ret ENDP pop namespace -#line 70 "arch/zx48k/opt1_dim_arr_local4.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 74 "arch/zx48k/opt1_dim_arr_local4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -599,7 +603,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -635,7 +639,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -663,9 +667,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 71 "arch/zx48k/opt1_dim_arr_local4.bas" +#line 75 "arch/zx48k/opt1_dim_arr_local4.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -824,7 +828,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 72 "arch/zx48k/opt1_dim_arr_local4.bas" +#line 76 "arch/zx48k/opt1_dim_arr_local4.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zx48k/pararray11.asm b/tests/functional/arch/zx48k/pararray11.asm index dc2151a8d..9e4f9bdc1 100644 --- a/tests/functional/arch/zx48k/pararray11.asm +++ b/tests/functional/arch/zx48k/pararray11.asm @@ -89,18 +89,18 @@ _func3: push ix ld ix, 0 add ix, sp - ld hl, -8 + ld hl, -10 add hl, sp ld sp, hl ld (hl), 0 - ld bc, 7 + ld bc, 9 ld d, h ld e, l inc de ldir ld hl, .LABEL.__LABEL6 push hl - ld hl, -8 + ld hl, -10 ld de, .LABEL.__LABEL5 ld bc, 8 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY @@ -113,7 +113,7 @@ _func3: push hl push ix pop hl - ld de, -8 + ld de, -10 add hl, de push hl call _func2 @@ -138,8 +138,8 @@ _func3: _func3__leave: ex af, af' exx - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-8) + ld h, (ix-7) call .core.__MEM_FREE ex af, af' exx @@ -147,7 +147,7 @@ _func3__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -208,8 +208,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -238,7 +238,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -266,7 +266,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -285,7 +285,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -293,7 +293,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -307,7 +307,7 @@ ARRAY_SIZE_LOOP: ENDP pop namespace #line 124 "arch/zx48k/pararray11.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -653,7 +653,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -689,7 +689,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -717,7 +717,7 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace #line 125 "arch/zx48k/pararray11.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" diff --git a/tests/functional/arch/zx48k/stdlib_spectranet.asm b/tests/functional/arch/zx48k/stdlib_spectranet.asm index db4a3b463..fe326055d 100644 --- a/tests/functional/arch/zx48k/stdlib_spectranet.asm +++ b/tests/functional/arch/zx48k/stdlib_spectranet.asm @@ -1030,11 +1030,16 @@ _SNETmount: push ix ld ix, 0 add ix, sp - ld hl, 0 - push hl - push hl - push hl - ld hl, -6 + ld hl, -8 + add hl, sp + ld sp, hl + ld (hl), 0 + ld bc, 7 + ld d, h + ld e, l + inc de + ldir + ld hl, -8 ld de, .LABEL.__LABEL38 ld bc, 10 call .core.__ALLOC_LOCAL_ARRAY @@ -1088,8 +1093,8 @@ _SNETmount: ld e, l ld bc, 14 call .core.__PSTORE_STR2 - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) push hl push ix pop hl @@ -1106,8 +1111,8 @@ _SNETmount: ld (hl), e inc hl ld (hl), d - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) inc hl inc hl push hl @@ -1126,8 +1131,8 @@ _SNETmount: ld (hl), e inc hl ld (hl), d - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) ld de, 4 add hl, de push hl @@ -1146,8 +1151,8 @@ _SNETmount: ld (hl), e inc hl ld (hl), d - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) ld de, 6 add hl, de push hl @@ -1166,8 +1171,8 @@ _SNETmount: ld (hl), e inc hl ld (hl), d - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) ld de, 8 add hl, de push hl @@ -1190,7 +1195,7 @@ _SNETmount: push hl push ix pop hl - ld de, -6 + ld de, -8 add hl, de call .core.__ARRAY ld (ix-2), l @@ -1222,8 +1227,8 @@ _SNETmount__leave: ld l, (ix+14) ld h, (ix+15) call .core.__MEM_FREE - ld l, (ix-4) - ld h, (ix-3) + ld l, (ix-6) + ld h, (ix-5) call .core.__MEM_FREE ex af, af' ld hl, 12 @@ -1590,7 +1595,7 @@ _SNETunlink__leave: DEFW 0001h DEFB 2Bh ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1651,8 +1656,8 @@ __FMUL16: djnz 1b ret pop namespace -#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" -#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 20 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" +#line 24 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" push namespace core __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) @@ -1681,7 +1686,7 @@ __ARRAY: inc hl ld b, (hl) ; BC <-- Array __LBOUND__ PTR ld (LBOUND_PTR), bc ; Store it for later -#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 66 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ; HL <-- PTR to Dim sizes table, DE <-- dummy ex (sp), hl ; Return address in HL, PTR Dim sizes table onto Stack ld (RET_ADDR), hl ; Stores it for later @@ -1709,7 +1714,7 @@ LOOP: 1: pop hl ; Get next index (Ai) from the stack sbc hl, bc ; Subtract LBOUND -#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 116 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" add hl, de ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -1728,7 +1733,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -1736,7 +1741,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array.asm" +#line 156 "/zxbasic/src/lib/arch/zx48k/runtime/array/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -1750,7 +1755,7 @@ ARRAY_SIZE_LOOP: ENDP pop namespace #line 458 "/zxbasic/src/lib/arch/zx48k/stdlib/spectranet.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -2096,7 +2101,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -2132,7 +2137,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -2160,7 +2165,7 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zx48k/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace #line 459 "/zxbasic/src/lib/arch/zx48k/stdlib/spectranet.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/asc.asm" diff --git a/tests/functional/arch/zx48k/ubound0.asm b/tests/functional/arch/zx48k/ubound0.asm index 854423613..438a58fcf 100644 --- a/tests/functional/arch/zx48k/ubound0.asm +++ b/tests/functional/arch/zx48k/ubound0.asm @@ -24,7 +24,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -40,9 +40,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 2 diff --git a/tests/functional/arch/zx48k/ubound1.asm b/tests/functional/arch/zx48k/ubound1.asm index 854423613..438a58fcf 100644 --- a/tests/functional/arch/zx48k/ubound1.asm +++ b/tests/functional/arch/zx48k/ubound1.asm @@ -24,7 +24,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -40,9 +40,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 2 diff --git a/tests/functional/arch/zx48k/ubound10.asm b/tests/functional/arch/zx48k/ubound10.asm index 16019ad11..a797b2013 100644 --- a/tests/functional/arch/zx48k/ubound10.asm +++ b/tests/functional/arch/zx48k/ubound10.asm @@ -119,8 +119,8 @@ _test3.a.__UBOUND__: DEFW 0005h DEFW 0009h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -131,7 +131,7 @@ _test3.a.__UBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -191,7 +191,7 @@ _test3.a.__UBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -225,8 +225,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -333,7 +333,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -364,9 +364,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -431,7 +431,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -465,7 +465,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -501,7 +501,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -553,12 +553,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS @@ -586,10 +589,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: exx call __ALLOC_INITIALIZED_LOCAL_ARRAY jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 92 "ubound10.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 92 "arch/zx48k/ubound10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -651,6 +654,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -663,8 +669,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 93 "ubound10.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 93 "arch/zx48k/ubound10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -822,7 +828,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 94 "ubound10.bas" +#line 94 "arch/zx48k/ubound10.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/ubound11.asm b/tests/functional/arch/zx48k/ubound11.asm index 6f11251c8..5b0a3ad77 100644 --- a/tests/functional/arch/zx48k/ubound11.asm +++ b/tests/functional/arch/zx48k/ubound11.asm @@ -135,8 +135,8 @@ _test3.a.__UBOUND__: DEFW 0005h DEFW 0009h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -147,7 +147,7 @@ _test3.a.__UBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -207,7 +207,7 @@ _test3.a.__UBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -241,8 +241,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -349,7 +349,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -380,9 +380,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -447,7 +447,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -481,7 +481,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -517,7 +517,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -569,12 +569,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS @@ -602,10 +605,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: exx call __ALLOC_INITIALIZED_LOCAL_ARRAY jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 108 "ubound11.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 108 "arch/zx48k/ubound11.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -667,6 +670,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -679,8 +685,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 109 "ubound11.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 109 "arch/zx48k/ubound11.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -838,7 +844,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 110 "ubound11.bas" +#line 110 "arch/zx48k/ubound11.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/ubound12.asm b/tests/functional/arch/zx48k/ubound12.asm index 42d567219..7f1d613df 100644 --- a/tests/functional/arch/zx48k/ubound12.asm +++ b/tests/functional/arch/zx48k/ubound12.asm @@ -137,8 +137,8 @@ _test2__leave: exx ret ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -149,7 +149,7 @@ _test2__leave: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -209,7 +209,7 @@ _test2__leave: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -243,8 +243,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -351,7 +351,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -382,9 +382,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -449,7 +449,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -483,7 +483,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -519,7 +519,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -571,12 +571,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS @@ -604,14 +607,14 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: exx call __ALLOC_INITIALIZED_LOCAL_ARRAY jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 110 "ubound12.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arraystrfree.asm" +#line 110 "arch/zx48k/ubound12.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -769,7 +772,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/arch/zx48k/library-asm/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -811,8 +814,8 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself pop hl ; recovers array block pointer jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace -#line 111 "ubound12.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 111 "arch/zx48k/ubound12.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -874,6 +877,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -886,7 +892,7 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 112 "ubound12.bas" +#line 112 "arch/zx48k/ubound12.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/ubound2.asm b/tests/functional/arch/zx48k/ubound2.asm index beb6a9185..316b47d9a 100644 --- a/tests/functional/arch/zx48k/ubound2.asm +++ b/tests/functional/arch/zx48k/ubound2.asm @@ -27,7 +27,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -43,9 +43,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h _a.__UBOUND__: DEFW 0005h DEFW 0009h @@ -133,6 +130,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/ubound3.asm b/tests/functional/arch/zx48k/ubound3.asm index 58c5db75e..1862e874a 100644 --- a/tests/functional/arch/zx48k/ubound3.asm +++ b/tests/functional/arch/zx48k/ubound3.asm @@ -24,7 +24,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW 0 _a.__DATA__: DEFB 00h @@ -40,9 +40,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: ld hl, 5 diff --git a/tests/functional/arch/zx48k/ubound4.asm b/tests/functional/arch/zx48k/ubound4.asm index a88fcc6de..2bc98f062 100644 --- a/tests/functional/arch/zx48k/ubound4.asm +++ b/tests/functional/arch/zx48k/ubound4.asm @@ -27,7 +27,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -43,9 +43,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h _a.__UBOUND__: DEFW 0005h DEFW 0009h @@ -133,6 +130,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/ubound5.asm b/tests/functional/arch/zx48k/ubound5.asm index c1b76d19d..5e0993ea5 100644 --- a/tests/functional/arch/zx48k/ubound5.asm +++ b/tests/functional/arch/zx48k/ubound5.asm @@ -27,7 +27,7 @@ _a: DEFW .LABEL.__LABEL0 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -43,9 +43,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h _a.__UBOUND__: DEFW 0005h DEFW 0009h @@ -133,6 +130,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/ubound6.asm b/tests/functional/arch/zx48k/ubound6.asm index 00f75dd98..dc4fedb48 100644 --- a/tests/functional/arch/zx48k/ubound6.asm +++ b/tests/functional/arch/zx48k/ubound6.asm @@ -103,8 +103,8 @@ _test.a.__UBOUND__: DEFW 0005h DEFW 0009h ;; --- end of user code --- -#line 1 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -115,7 +115,7 @@ _test.a.__UBOUND__: ; closed source programs). ; ; Please read the MIT license on the internet -#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -175,7 +175,7 @@ _test.a.__UBOUND__: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/error.asm" ; Simple error control routines ; vim:ts=4:et: push namespace core @@ -209,8 +209,8 @@ __STOP: ld (ERR_NR), a ret pop namespace -#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" +#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -317,7 +317,7 @@ __MEM_INIT2: ret ENDP pop namespace -#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 70 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -348,9 +348,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ret z ; NULL -#line 115 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 115 "/zxbasic/src/lib/arch/zx48k/runtime/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -415,7 +415,7 @@ __MEM_SUBTRACT: ret ENDP pop namespace -#line 13 "/zxbasic/src/arch/zx48k/library-asm/calloc.asm" +#line 13 "/zxbasic/src/lib/arch/zx48k/runtime/calloc.asm" ; --------------------------------------------------------------------- ; MEM_CALLOC ; Allocates a block of memory in the heap, and clears it filling it @@ -449,7 +449,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -485,7 +485,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -537,12 +537,15 @@ __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2: ld (hl), e inc hl ld (hl), d - pop de + pop de ;; PTR to ubound table + push bc ;; puts ret address back + ld a, d + or e + ret z ;; if PTR for UBound is 0, it's not used inc hl ld (hl), e inc hl ld (hl), d - push bc ret ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS @@ -570,10 +573,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY_WITH_BOUNDS: exx call __ALLOC_INITIALIZED_LOCAL_ARRAY jp __ALLOC_LOCAL_ARRAY_WITH_BOUNDS2 -#line 139 "/zxbasic/src/arch/zx48k/library-asm/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zx48k/runtime/array/arrayalloc.asm" pop namespace -#line 76 "ubound6.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/bound.asm" +#line 76 "arch/zx48k/ubound6.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bound.asm" ; --------------------------------------------------------- ; Copyleft (k)2011 by Jose Rodriguez (a.k.a. Boriel) ; http://www.boriel.com @@ -635,6 +638,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl @@ -647,8 +653,8 @@ __DIM_NOT_EXIST: ret ENDP pop namespace -#line 77 "ubound6.bas" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" +#line 77 "arch/zx48k/ubound6.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -806,7 +812,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 78 "ubound6.bas" +#line 78 "arch/zx48k/ubound6.bas" .LABEL.__LABEL5: DEFB 01h DEFB 00h diff --git a/tests/functional/arch/zx48k/ubound7.asm b/tests/functional/arch/zx48k/ubound7.asm index a0cb8ac3b..da130b9a4 100644 --- a/tests/functional/arch/zx48k/ubound7.asm +++ b/tests/functional/arch/zx48k/ubound7.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL5 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -42,9 +42,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h _a.__UBOUND__: DEFW 0005h DEFW 0009h @@ -168,6 +165,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/ubound8.asm b/tests/functional/arch/zx48k/ubound8.asm index 356614e4e..9395bcc7a 100644 --- a/tests/functional/arch/zx48k/ubound8.asm +++ b/tests/functional/arch/zx48k/ubound8.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL5 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -42,9 +42,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h _a.__UBOUND__: DEFW 0005h DEFW 0009h @@ -163,6 +160,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zx48k/ubound9.asm b/tests/functional/arch/zx48k/ubound9.asm index d158ff283..5b36fa2a1 100644 --- a/tests/functional/arch/zx48k/ubound9.asm +++ b/tests/functional/arch/zx48k/ubound9.asm @@ -26,7 +26,7 @@ _a: DEFW .LABEL.__LABEL5 _a.__DATA__.__PTR__: DEFW _a.__DATA__ - DEFW _a.__LBOUND__ + DEFW 0 DEFW _a.__UBOUND__ _a.__DATA__: DEFB 00h @@ -42,9 +42,6 @@ _a.__DATA__: DEFW 0001h DEFW 0003h DEFB 01h -_a.__LBOUND__: - DEFW 0003h - DEFW 0007h _a.__UBOUND__: DEFW 0005h DEFW 0009h @@ -179,6 +176,9 @@ __CONT: inc hl ld h, (hl) ld l, a ; LD HL, (HL) => Origin of L/U Bound table + ; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based + or h + ret z ; Should never happen for UBound add hl, de ; hl += OFFSET __LBOUND._xxxx ld e, (hl) ; de = (hl) inc hl diff --git a/tests/functional/arch/zxnext/arraycopy1.asm b/tests/functional/arch/zxnext/arraycopy1.asm index 5157d6c4d..f575b2854 100644 --- a/tests/functional/arch/zxnext/arraycopy1.asm +++ b/tests/functional/arch/zxnext/arraycopy1.asm @@ -54,12 +54,13 @@ _Test: ld hl, 0 push hl push hl - ld hl, -4 + push hl + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 5 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 5 ld b, h @@ -70,8 +71,8 @@ _Test: _Test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -79,7 +80,7 @@ _Test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -425,7 +426,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -461,7 +462,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -489,9 +490,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" pop namespace -#line 44 "arch/zxnext/arraycopy1.bas" +#line 45 "arch/zxnext/arraycopy1.bas" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -650,7 +651,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 45 "arch/zxnext/arraycopy1.bas" +#line 46 "arch/zxnext/arraycopy1.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zxnext/arraycopy2.asm b/tests/functional/arch/zxnext/arraycopy2.asm index 87c41f96f..bedc5370f 100644 --- a/tests/functional/arch/zxnext/arraycopy2.asm +++ b/tests/functional/arch/zxnext/arraycopy2.asm @@ -54,14 +54,15 @@ _Test: ld hl, 0 push hl push hl + push hl ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 5 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 5 ld b, h @@ -72,8 +73,8 @@ _Test: _Test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE ex af, af' exx @@ -81,7 +82,7 @@ _Test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -427,7 +428,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -463,7 +464,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -491,9 +492,9 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" pop namespace -#line 46 "arch/zxnext/arraycopy2.bas" +#line 47 "arch/zxnext/arraycopy2.bas" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -652,7 +653,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 47 "arch/zxnext/arraycopy2.bas" +#line 48 "arch/zxnext/arraycopy2.bas" .LABEL.__LABEL0: DEFB 00h DEFB 00h diff --git a/tests/functional/arch/zxnext/arraycopy3.asm b/tests/functional/arch/zxnext/arraycopy3.asm index c1c4d5fc8..19b013233 100644 --- a/tests/functional/arch/zxnext/arraycopy3.asm +++ b/tests/functional/arch/zxnext/arraycopy3.asm @@ -36,30 +36,30 @@ _Test: push ix ld ix, 0 add ix, sp - ld hl, -8 + ld hl, -12 add hl, sp ld sp, hl ld (hl), 0 - ld bc, 7 + ld bc, 11 ld d, h ld e, l inc de ldir ld hl, .LABEL.__LABEL1 push hl - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 5 call .core.__ALLOC_INITIALIZED_LOCAL_ARRAY - ld hl, -8 + ld hl, -12 ld de, .LABEL.__LABEL2 ld bc, 5 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 5 ld b, h @@ -70,11 +70,11 @@ _Test: _Test__leave: ex af, af' exx - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__MEM_FREE - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) call .core.__MEM_FREE ex af, af' exx @@ -82,7 +82,7 @@ _Test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -428,7 +428,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -464,7 +464,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -492,7 +492,7 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" pop namespace #line 62 "arch/zxnext/arraycopy3.bas" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/free.asm" diff --git a/tests/functional/arch/zxnext/arraycopy4.asm b/tests/functional/arch/zxnext/arraycopy4.asm index cbfde9004..e2e961dcb 100644 --- a/tests/functional/arch/zxnext/arraycopy4.asm +++ b/tests/functional/arch/zxnext/arraycopy4.asm @@ -37,28 +37,28 @@ _test: push ix ld ix, 0 add ix, sp - ld hl, -8 + ld hl, -12 add hl, sp ld sp, hl ld (hl), 0 - ld bc, 7 + ld bc, 11 ld d, h ld e, l inc de ldir - ld hl, -4 + ld hl, -6 ld de, .LABEL.__LABEL0 ld bc, 22 call .core.__ALLOC_LOCAL_ARRAY - ld hl, -8 + ld hl, -12 ld de, .LABEL.__LABEL1 ld bc, 22 call .core.__ALLOC_LOCAL_ARRAY - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) push hl ld hl, 11 push hl @@ -68,13 +68,13 @@ _test__leave: exx ld hl, 11 push hl - ld l, (ix-2) - ld h, (ix-1) + ld l, (ix-4) + ld h, (ix-3) call .core.__ARRAYSTR_FREE_MEM ld hl, 11 push hl - ld l, (ix-6) - ld h, (ix-5) + ld l, (ix-10) + ld h, (ix-9) call .core.__ARRAYSTR_FREE_MEM ex af, af' exx @@ -82,7 +82,7 @@ _test__leave: pop ix ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/calloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa @@ -428,7 +428,7 @@ __MEM_CALLOC: pop hl ret pop namespace -#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 3 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" ; --------------------------------------------------------------------- ; __ALLOC_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it @@ -464,7 +464,7 @@ __ALLOC_LOCAL_ARRAY: ; --------------------------------------------------------------------- ; __ALLOC_INITIALIZED_LOCAL_ARRAY ; Allocates an array element area in the heap, and clears it filling it - ; with 0 bytes + ; with data whose pointer (PTR) is in the stack ; ; Parameters ; HL = Offset to be added to IX => HL = IX + HL @@ -492,10 +492,10 @@ __ALLOC_INITIALIZED_LOCAL_ARRAY: ldir pop hl ; HL = addr of LBound area if used ret -#line 139 "/zxbasic/src/lib/arch/zxnext/runtime/arrayalloc.asm" +#line 142 "/zxbasic/src/lib/arch/zxnext/runtime/array/arrayalloc.asm" pop namespace #line 62 "arch/zxnext/arraycopy4.bas" -#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/arraystrfree.asm" +#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/array/arraystrfree.asm" ; This routine is in charge of freeing an array of strings from memory ; HL = Pointer to start of array in memory ; Top of the stack = Number of elements of the array @@ -657,7 +657,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ret ENDP pop namespace -#line 6 "/zxbasic/src/lib/arch/zxnext/runtime/arraystrfree.asm" +#line 6 "/zxbasic/src/lib/arch/zxnext/runtime/array/arraystrfree.asm" push namespace core __ARRAYSTR_FREE: PROC @@ -700,7 +700,7 @@ __ARRAYSTR_FREE_MEM: ; like the above, buf also frees the array itself jp __MEM_FREE ; Frees it and returns from __MEM_FREE pop namespace #line 63 "arch/zxnext/arraycopy4.bas" -#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/strarraycpy.asm" +#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/array/strarraycpy.asm" ; (K)opyleft - by Jose M. Rodriguez de la Rosa (a.k.a. Boriel) ; 2009 - This is Free OpenSource BSD code ; vim: et:ts=4:sw=4 @@ -723,7 +723,7 @@ __LOAD_DE_DE: ex de, hl ret pop namespace -#line 11 "/zxbasic/src/lib/arch/zxnext/runtime/strarraycpy.asm" +#line 11 "/zxbasic/src/lib/arch/zxnext/runtime/array/strarraycpy.asm" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/strcpy.asm" #line 1 "/zxbasic/src/lib/arch/zxnext/runtime/realloc.asm" ; vim: ts=4:et:sw=4: @@ -934,7 +934,7 @@ __NOTHING_TO_COPY: ret ENDP pop namespace -#line 12 "/zxbasic/src/lib/arch/zxnext/runtime/strarraycpy.asm" +#line 12 "/zxbasic/src/lib/arch/zxnext/runtime/array/strarraycpy.asm" push namespace core STR_ARRAYCOPY: ; Copies an array of string a$ = b$ diff --git a/tests/symbols/test_symbolVARARRAY.py b/tests/symbols/test_symbolVARARRAY.py index caa273488..9e4d5c297 100644 --- a/tests/symbols/test_symbolVARARRAY.py +++ b/tests/symbols/test_symbolVARARRAY.py @@ -35,4 +35,4 @@ def test_size(self): self.assertEqual(self.arr.size, self.arr.type_.size * self.arr.count) def test_memsize(self): - self.assertEqual(self.arr.memsize, 2 * TYPE.size(gl.PTR_TYPE)) + self.assertEqual(self.arr.memsize, 3 * TYPE.size(gl.PTR_TYPE))