Skip to content

Commit b919952

Browse files
committed
Add tests
1 parent 6d3f89e commit b919952

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

tests/functional/ubyteopt.asm

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 a, 2
22+
push af
23+
ld a, 1
24+
push af
25+
call _CanDraw
26+
ld hl, 0
27+
ld b, h
28+
ld c, l
29+
__END_PROGRAM:
30+
di
31+
ld hl, (__CALL_BACK__)
32+
ld sp, hl
33+
exx
34+
pop hl
35+
exx
36+
pop iy
37+
pop ix
38+
ei
39+
ret
40+
__CALL_BACK__:
41+
DEFW 0
42+
_CanDraw:
43+
push ix
44+
ld ix, 0
45+
add ix, sp
46+
ld a, (ix+7)
47+
push af
48+
ld h, 0
49+
pop af
50+
cp h
51+
sbc a, a
52+
push af
53+
ld a, (ix+5)
54+
push af
55+
ld h, 0
56+
pop af
57+
cp h
58+
sbc a, a
59+
pop de
60+
or d
61+
push af
62+
ld a, (ix+7)
63+
push af
64+
ld a, 20
65+
pop hl
66+
cp h
67+
sbc a, a
68+
pop de
69+
or d
70+
push af
71+
ld a, (ix+5)
72+
push af
73+
ld a, 31
74+
pop hl
75+
cp h
76+
sbc a, a
77+
pop de
78+
or d
79+
jp z, __LABEL1
80+
xor a
81+
jp _CanDraw__leave
82+
__LABEL1:
83+
ld a, 1
84+
_CanDraw__leave:
85+
ld sp, ix
86+
pop ix
87+
exx
88+
pop hl
89+
pop bc
90+
ex (sp), hl
91+
exx
92+
ret
93+
END

tests/functional/ubyteopt.bas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function CanDraw(x as ubyte, y as ubyte) as ubyte
2+
if y<0 or x<0 or y>20 or x>31 then return 0
3+
return 1
4+
end function
5+
6+
CanDraw(1, 2)

0 commit comments

Comments
 (0)