Skip to content

Commit e5d5888

Browse files
committed
fix: update bound routine in zxnext
1 parent eae716b commit e5d5888

File tree

13 files changed

+770
-0
lines changed

13 files changed

+770
-0
lines changed

src/lib/arch/zxnext/runtime/bound.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ __CONT:
7070
ld h, (hl)
7171
ld l, a ; LD HL, (HL) => Origin of L/U Bound table
7272

73+
; for LBound only, HL = 0x0000 (NULL) if the array is all 0-based
74+
or h
75+
ret z ; Should never happen for UBound
76+
7377
add hl, de ; hl += OFFSET __LBOUND._xxxx
7478
ld e, (hl) ; de = (hl)
7579
inc hl
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld hl, 0
7+
add hl, sp
8+
ld (.core.__CALL_BACK__), hl
9+
ei
10+
jp .core.__MAIN_PROGRAM__
11+
.core.__CALL_BACK__:
12+
DEFW 0
13+
.core.ZXBASIC_USER_DATA:
14+
; Defines USER DATA Length in bytes
15+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
16+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
17+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
18+
_b:
19+
DEFB 00, 00
20+
_c:
21+
DEFB 00, 00
22+
_a:
23+
DEFW .LABEL.__LABEL0
24+
_a.__DATA__.__PTR__:
25+
DEFW _a.__DATA__
26+
DEFW 0
27+
DEFW 0
28+
_a.__DATA__:
29+
DEFB 00h
30+
DEFB 00h
31+
DEFB 00h
32+
DEFB 00h
33+
DEFB 00h
34+
DEFB 00h
35+
DEFB 00h
36+
DEFB 00h
37+
DEFB 00h
38+
DEFB 00h
39+
DEFB 00h
40+
DEFB 00h
41+
DEFB 00h
42+
DEFB 00h
43+
.LABEL.__LABEL0:
44+
DEFW 0000h
45+
DEFB 02h
46+
.core.ZXBASIC_USER_DATA_END:
47+
.core.__MAIN_PROGRAM__:
48+
ld hl, 1
49+
ld (_b), hl
50+
ld hl, 1
51+
ld (_c), hl
52+
ld hl, 0
53+
ld b, h
54+
ld c, l
55+
.core.__END_PROGRAM:
56+
di
57+
ld hl, (.core.__CALL_BACK__)
58+
ld sp, hl
59+
pop iy
60+
ei
61+
ret
62+
;; --- end of user code ---
63+
END
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
DIM a(2 TO 8) as integer
3+
4+
LET b = Ubound(a)
5+
LET c = Lbound(a)
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld hl, 0
7+
add hl, sp
8+
ld (.core.__CALL_BACK__), hl
9+
ei
10+
jp .core.__MAIN_PROGRAM__
11+
.core.__CALL_BACK__:
12+
DEFW 0
13+
.core.ZXBASIC_USER_DATA:
14+
; Defines USER DATA Length in bytes
15+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
16+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
17+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
18+
_b:
19+
DEFB 00, 00
20+
_c:
21+
DEFB 00, 00
22+
_a:
23+
DEFW .LABEL.__LABEL0
24+
_a.__DATA__.__PTR__:
25+
DEFW _a.__DATA__
26+
DEFW 0
27+
DEFW 0
28+
_a.__DATA__:
29+
DEFB 00h
30+
DEFB 00h
31+
DEFB 00h
32+
DEFB 00h
33+
DEFB 00h
34+
DEFB 00h
35+
DEFB 00h
36+
DEFB 00h
37+
DEFB 00h
38+
DEFB 00h
39+
DEFB 00h
40+
DEFB 00h
41+
DEFB 00h
42+
DEFB 00h
43+
DEFB 00h
44+
DEFB 00h
45+
DEFB 00h
46+
DEFB 00h
47+
DEFB 00h
48+
DEFB 00h
49+
DEFB 00h
50+
DEFB 00h
51+
DEFB 00h
52+
DEFB 00h
53+
DEFB 00h
54+
DEFB 00h
55+
DEFB 00h
56+
DEFB 00h
57+
DEFB 00h
58+
DEFB 00h
59+
DEFB 00h
60+
DEFB 00h
61+
DEFB 00h
62+
DEFB 00h
63+
DEFB 00h
64+
DEFB 00h
65+
DEFB 00h
66+
DEFB 00h
67+
DEFB 00h
68+
DEFB 00h
69+
DEFB 00h
70+
DEFB 00h
71+
DEFB 00h
72+
DEFB 00h
73+
DEFB 00h
74+
DEFB 00h
75+
DEFB 00h
76+
DEFB 00h
77+
DEFB 00h
78+
DEFB 00h
79+
DEFB 00h
80+
DEFB 00h
81+
DEFB 00h
82+
DEFB 00h
83+
DEFB 00h
84+
DEFB 00h
85+
.LABEL.__LABEL0:
86+
DEFW 0001h
87+
DEFW 0004h
88+
DEFB 02h
89+
.core.ZXBASIC_USER_DATA_END:
90+
.core.__MAIN_PROGRAM__:
91+
ld hl, 8
92+
ld (_b), hl
93+
ld hl, 2
94+
ld (_c), hl
95+
ld hl, 6
96+
ld (_b), hl
97+
ld hl, 3
98+
ld (_c), hl
99+
ld hl, 0
100+
ld b, h
101+
ld c, l
102+
.core.__END_PROGRAM:
103+
di
104+
ld hl, (.core.__CALL_BACK__)
105+
ld sp, hl
106+
pop iy
107+
ei
108+
ret
109+
;; --- end of user code ---
110+
END
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
DIM a(2 TO 8, 3 TO 6) as integer
3+
4+
LET b = Ubound(a, 1)
5+
LET c = Lbound(a, 1)
6+
LET b = Ubound(a, 2)
7+
LET c = Lbound(a, 2)

0 commit comments

Comments
 (0)