Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/arch/zxnext/runtime/bound.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 63 additions & 0 deletions tests/functional/arch/zxnext/bound00.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
org 32768
.core.__START_PROGRAM:
di
push iy
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
ld hl, 0
add hl, sp
ld (.core.__CALL_BACK__), hl
ei
jp .core.__MAIN_PROGRAM__
.core.__CALL_BACK__:
DEFW 0
.core.ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
_b:
DEFB 00, 00
_c:
DEFB 00, 00
_a:
DEFW .LABEL.__LABEL0
_a.__DATA__.__PTR__:
DEFW _a.__DATA__
DEFW 0
DEFW 0
_a.__DATA__:
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
.LABEL.__LABEL0:
DEFW 0000h
DEFB 02h
.core.ZXBASIC_USER_DATA_END:
.core.__MAIN_PROGRAM__:
ld hl, 1
ld (_b), hl
ld hl, 1
ld (_c), hl
ld hl, 0
ld b, h
ld c, l
.core.__END_PROGRAM:
di
ld hl, (.core.__CALL_BACK__)
ld sp, hl
pop iy
ei
ret
;; --- end of user code ---
END
5 changes: 5 additions & 0 deletions tests/functional/arch/zxnext/bound00.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

DIM a(2 TO 8) as integer

LET b = Ubound(a)
LET c = Lbound(a)
110 changes: 110 additions & 0 deletions tests/functional/arch/zxnext/bound01.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
org 32768
.core.__START_PROGRAM:
di
push iy
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
ld hl, 0
add hl, sp
ld (.core.__CALL_BACK__), hl
ei
jp .core.__MAIN_PROGRAM__
.core.__CALL_BACK__:
DEFW 0
.core.ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
_b:
DEFB 00, 00
_c:
DEFB 00, 00
_a:
DEFW .LABEL.__LABEL0
_a.__DATA__.__PTR__:
DEFW _a.__DATA__
DEFW 0
DEFW 0
_a.__DATA__:
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
DEFB 00h
.LABEL.__LABEL0:
DEFW 0001h
DEFW 0004h
DEFB 02h
.core.ZXBASIC_USER_DATA_END:
.core.__MAIN_PROGRAM__:
ld hl, 8
ld (_b), hl
ld hl, 2
ld (_c), hl
ld hl, 6
ld (_b), hl
ld hl, 3
ld (_c), hl
ld hl, 0
ld b, h
ld c, l
.core.__END_PROGRAM:
di
ld hl, (.core.__CALL_BACK__)
ld sp, hl
pop iy
ei
ret
;; --- end of user code ---
END
7 changes: 7 additions & 0 deletions tests/functional/arch/zxnext/bound01.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

DIM a(2 TO 8, 3 TO 6) as integer

LET b = Ubound(a, 1)
LET c = Lbound(a, 1)
LET b = Ubound(a, 2)
LET c = Lbound(a, 2)
Loading