Skip to content

Commit 919531e

Browse files
committed
Add tests
Also update test opt2_unused_var.bas which reflects a bugfix.
1 parent f320dbb commit 919531e

5 files changed

Lines changed: 182 additions & 7 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
jp __MAIN_PROGRAM__
14+
ZXBASIC_USER_DATA:
15+
; Defines USER DATA Length in bytes
16+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
17+
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
18+
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
19+
ZXBASIC_USER_DATA_END:
20+
__MAIN_PROGRAM__:
21+
ld hl, 0
22+
ld b, h
23+
ld c, l
24+
__END_PROGRAM:
25+
di
26+
ld hl, (__CALL_BACK__)
27+
ld sp, hl
28+
exx
29+
pop hl
30+
pop iy
31+
pop ix
32+
exx
33+
ei
34+
ret
35+
__CALL_BACK__:
36+
DEFW 0
37+
ld hl, 0
38+
ld b, h
39+
ld c, l
40+
jp __END_PROGRAM
41+
_MultiKeys:
42+
push ix
43+
ld ix, 0
44+
add ix, sp
45+
ld a, (ix+5)
46+
_MultiKeys__leave:
47+
ld sp, ix
48+
pop ix
49+
exx
50+
pop hl
51+
ex (sp), hl
52+
exx
53+
ret
54+
_mainRoom:
55+
xor a
56+
push af
57+
call _MultiKeys
58+
or a
59+
jp z, __LABEL1
60+
ld a, 1
61+
ld (0), a
62+
__LABEL1:
63+
ld a, 1
64+
push af
65+
call _MultiKeys
66+
or a
67+
jp z, __LABEL3
68+
xor a
69+
ld (1), a
70+
__LABEL3:
71+
ld a, 2
72+
push af
73+
call _MultiKeys
74+
or a
75+
jp z, __LABEL5
76+
xor a
77+
ld (2), a
78+
__LABEL5:
79+
_mainRoom__leave:
80+
ret
81+
END
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
function MultiKeys(x as Ubyte) as Ubyte
3+
return x
4+
end function
5+
6+
7+
sub fastcall mainRoom()
8+
IF MultiKeys(0) then
9+
poke 0,1
10+
end if
11+
12+
IF MultiKeys(1) then
13+
poke 1,0
14+
end if
15+
16+
if MultiKeys(2) then
17+
poke 2,0
18+
end if
19+
20+
end sub
21+
22+
end
23+
24+
DIM dummy as Uinteger
25+
dummy=@mainRoom

tests/functional/opt2_unused_var.asm

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,11 @@ _Check:
6363
ld a, 5
6464
push af
6565
call _TestPrint
66-
push bc
67-
push de
68-
push af
6966
ld a, 11
7067
push af
7168
ld a, 6
7269
push af
7370
call _TestPrint
74-
push bc
75-
push de
76-
push af
7771
_Check__leave:
7872
ld sp, ix
7973
pop ix
@@ -84,5 +78,5 @@ __PAUSE:
8478
ld b, h
8579
ld c, l
8680
jp 1F3Dh ; PAUSE_1
87-
#line 62 "opt2_unused_var.bas"
81+
#line 56 "opt2_unused_var.bas"
8882
END
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
jp __MAIN_PROGRAM__
14+
ZXBASIC_USER_DATA:
15+
; Defines USER DATA Length in bytes
16+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
17+
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
18+
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
19+
_a:
20+
DEFB 00
21+
ZXBASIC_USER_DATA_END:
22+
__MAIN_PROGRAM__:
23+
xor a
24+
push af
25+
call _test
26+
ld (_a), a
27+
ld hl, 0
28+
ld b, h
29+
ld c, l
30+
__END_PROGRAM:
31+
di
32+
ld hl, (__CALL_BACK__)
33+
ld sp, hl
34+
exx
35+
pop hl
36+
exx
37+
pop iy
38+
pop ix
39+
ei
40+
ret
41+
__CALL_BACK__:
42+
DEFW 0
43+
_test:
44+
push ix
45+
ld ix, 0
46+
add ix, sp
47+
ld a, (ix+5)
48+
push af
49+
ld h, 10
50+
pop af
51+
cp h
52+
jp nc, __LABEL1
53+
ld a, (ix+5)
54+
jp _test__leave
55+
__LABEL1:
56+
ld a, (ix+5)
57+
_test__leave:
58+
ld sp, ix
59+
pop ix
60+
exx
61+
pop hl
62+
ex (sp), hl
63+
exx
64+
ret
65+
END
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DIM a as UByte
2+
FUNCTION test(a as UByte) as UByte
3+
IF a < 10 THEN
4+
RETURN a
5+
END IF
6+
RETURN a
7+
END FUNCTION
8+
9+
LET a = test(0)
10+

0 commit comments

Comments
 (0)