Skip to content

Commit 8a410c9

Browse files
committed
Add also SHL/SHR test
Add forgotten test from the SHL / SHR fix
1 parent 39a3f34 commit 8a410c9

4 files changed

Lines changed: 258 additions & 0 deletions

File tree

tests/functional/shl_shr_16bit.asm

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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 00h
21+
_result:
22+
DEFB 00, 00
23+
ZXBASIC_USER_DATA_END:
24+
__MAIN_PROGRAM__:
25+
ld hl, 32767
26+
ld (_result), hl
27+
ld a, (_a)
28+
ld b, a
29+
ld hl, 32767
30+
or a
31+
jr z, __LABEL1
32+
__LABEL0:
33+
srl h
34+
rr l
35+
djnz __LABEL0
36+
__LABEL1:
37+
ld (_result), hl
38+
ld hl, 32767
39+
ld (_result), hl
40+
ld a, (_a)
41+
ld b, a
42+
ld hl, 32767
43+
or a
44+
jr z, __LABEL3
45+
__LABEL2:
46+
add hl, hl
47+
djnz __LABEL2
48+
__LABEL3:
49+
ld (_result), hl
50+
ld hl, 65024
51+
ld (_result), hl
52+
ld a, (_a)
53+
ld b, a
54+
ld hl, 65024
55+
or a
56+
jr z, __LABEL5
57+
__LABEL4:
58+
sra h
59+
rr l
60+
djnz __LABEL4
61+
__LABEL5:
62+
ld (_result), hl
63+
ld hl, 65024
64+
ld (_result), hl
65+
ld a, (_a)
66+
ld b, a
67+
ld hl, 65024
68+
or a
69+
jr z, __LABEL7
70+
__LABEL6:
71+
add hl, hl
72+
djnz __LABEL6
73+
__LABEL7:
74+
ld (_result), hl
75+
ld hl, 0
76+
ld b, h
77+
ld c, l
78+
__END_PROGRAM:
79+
di
80+
ld hl, (__CALL_BACK__)
81+
ld sp, hl
82+
exx
83+
pop hl
84+
exx
85+
pop iy
86+
pop ix
87+
ei
88+
ret
89+
__CALL_BACK__:
90+
DEFW 0
91+
;; --- end of user code ---
92+
END

tests/functional/shl_shr_16bit.bas

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
DIM a as UByte = 0
3+
DIM result as UInteger
4+
5+
LET result = (0x7FFF >> 0)
6+
LET result = (0x7FFF >> a)
7+
8+
LET result = (0x7FFF << 0)
9+
LET result = (0x7FFF << a)
10+
11+
LET result = (-512 >> 0)
12+
LET result = (-512 >> a)
13+
14+
LET result = (-512 << 0)
15+
LET result = (-512 << a)
16+

tests/functional/shl_shr_32bit.asm

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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 00h
21+
_c:
22+
DEFB 0FFh
23+
DEFB 7Fh
24+
DEFB 00h
25+
DEFB 00h
26+
_d:
27+
DEFB 00h
28+
DEFB 0FEh
29+
DEFB 0FFh
30+
DEFB 0FFh
31+
_result:
32+
DEFB 00, 00
33+
ZXBASIC_USER_DATA_END:
34+
__MAIN_PROGRAM__:
35+
ld hl, (_c)
36+
ld de, (_c + 2)
37+
ld (_result), hl
38+
ld a, (_a)
39+
ld b, a
40+
ld hl, (_c)
41+
ld de, (_c + 2)
42+
or a
43+
jr z, __LABEL1
44+
__LABEL0:
45+
call __SHRL32
46+
djnz __LABEL0
47+
__LABEL1:
48+
ld (_result), hl
49+
ld hl, (_c)
50+
ld de, (_c + 2)
51+
ld (_result), hl
52+
ld a, (_a)
53+
ld b, a
54+
ld hl, (_c)
55+
ld de, (_c + 2)
56+
or a
57+
jr z, __LABEL3
58+
__LABEL2:
59+
call __SHL32
60+
djnz __LABEL2
61+
__LABEL3:
62+
ld (_result), hl
63+
ld hl, (_d)
64+
ld de, (_d + 2)
65+
ld (_result), hl
66+
ld a, (_a)
67+
ld b, a
68+
ld hl, (_d)
69+
ld de, (_d + 2)
70+
or a
71+
jr z, __LABEL5
72+
__LABEL4:
73+
call __SHRA32
74+
djnz __LABEL4
75+
__LABEL5:
76+
ld (_result), hl
77+
ld hl, (_d)
78+
ld de, (_d + 2)
79+
ld (_result), hl
80+
ld a, (_a)
81+
ld b, a
82+
ld hl, (_d)
83+
ld de, (_d + 2)
84+
or a
85+
jr z, __LABEL7
86+
__LABEL6:
87+
call __SHL32
88+
djnz __LABEL6
89+
__LABEL7:
90+
ld (_result), hl
91+
ld hl, 0
92+
ld b, h
93+
ld c, l
94+
__END_PROGRAM:
95+
di
96+
ld hl, (__CALL_BACK__)
97+
ld sp, hl
98+
exx
99+
pop hl
100+
exx
101+
pop iy
102+
pop ix
103+
ei
104+
ret
105+
__CALL_BACK__:
106+
DEFW 0
107+
;; --- end of user code ---
108+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/shl32.asm"
109+
__SHL32: ; Left Logical Shift 32 bits
110+
sla l
111+
rl h
112+
rl e
113+
rl d
114+
ret
115+
#line 75 "shl_shr_32bit.bas"
116+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/shra32.asm"
117+
__SHRA32: ; Right Arithmetical Shift 32 bits
118+
sra d
119+
rr e
120+
rr h
121+
rr l
122+
ret
123+
#line 76 "shl_shr_32bit.bas"
124+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/shrl32.asm"
125+
__SHRL32: ; Right Logical Shift 32 bits
126+
srl d
127+
rr e
128+
rr h
129+
rr l
130+
ret
131+
#line 77 "shl_shr_32bit.bas"
132+
END

tests/functional/shl_shr_32bit.bas

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
DIM a as UByte = 0
3+
DIM c as ULong = 0x7FFF
4+
DIM d as Long = -512
5+
DIM result as UInteger
6+
7+
LET result = (c >> 0)
8+
LET result = (c >> a)
9+
10+
LET result = (c << 0)
11+
LET result = (c << a)
12+
13+
LET result = (d >> 0)
14+
LET result = (d >> a)
15+
16+
LET result = (d << 0)
17+
LET result = (d << a)
18+

0 commit comments

Comments
 (0)