Skip to content

Commit 278a679

Browse files
committed
Fix SHRU16 for constant value
1 parent 34ca4d1 commit 278a679

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

src/arch/zx48k/backend/__16bit.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,9 @@ def _shru16(ins):
886886
Shift Right Arithmetic
887887
"""
888888
op1, op2 = tuple(ins.quad[2:])
889+
label = tmp_label()
890+
label2 = tmp_label()
891+
889892
if is_int(op2):
890893
op = int16(op2)
891894
if op == 0:
@@ -903,11 +906,9 @@ def _shru16(ins):
903906
output = _8bit_oper(op2)
904907
output.append('ld b, a')
905908
output.extend(_16bit_oper(op1))
909+
output.append('or a')
910+
output.append('jr z, %s' % label2)
906911

907-
label = tmp_label()
908-
label2 = tmp_label()
909-
output.append('or a')
910-
output.append('jr z, %s' % label2)
911912
output.append('%s:' % label)
912913
output.append('srl h')
913914
output.append('rr l')
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
org 32768
2+
.core.__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 (.core.__CALL_BACK__), hl
12+
ei
13+
jp .core.__MAIN_PROGRAM__
14+
.core.__CALL_BACK__:
15+
DEFW 0
16+
.core.ZXBASIC_USER_DATA:
17+
; Defines USER DATA Length in bytes
18+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
19+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
20+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
21+
_num1:
22+
DEFB 00, 00
23+
_num2:
24+
DEFB 00, 00
25+
.core.ZXBASIC_USER_DATA_END:
26+
.core.__MAIN_PROGRAM__:
27+
ld hl, (_num1)
28+
ld b, 3
29+
.LABEL.__LABEL0:
30+
srl h
31+
rr l
32+
djnz .LABEL.__LABEL0
33+
.LABEL.__LABEL1:
34+
ld (_num2), hl
35+
ld hl, 0
36+
ld b, h
37+
ld c, l
38+
.core.__END_PROGRAM:
39+
di
40+
ld hl, (.core.__CALL_BACK__)
41+
ld sp, hl
42+
exx
43+
pop hl
44+
exx
45+
pop iy
46+
pop ix
47+
ei
48+
ret
49+
;; --- end of user code ---
50+
END
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dim num1, num2 as uinteger
2+
num2 = num1 >> 3
3+

0 commit comments

Comments
 (0)