Skip to content

Commit e7ae259

Browse files
committed
Fix SHL16 for constant value
1 parent 17c869f commit e7ae259

3 files changed

Lines changed: 56 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
@@ -974,6 +974,9 @@ def _shl16(ins):
974974
unroll lop
975975
"""
976976
op1, op2 = tuple(ins.quad[2:])
977+
label = tmp_label()
978+
label2 = tmp_label()
979+
977980
if is_int(op2):
978981
op = int16(op2)
979982
if op == 0:
@@ -990,11 +993,9 @@ def _shl16(ins):
990993
output = _8bit_oper(op2)
991994
output.append('ld b, a')
992995
output.extend(_16bit_oper(op1))
996+
output.append('or a')
997+
output.append('jr z, %s' % label2)
993998

994-
label = tmp_label()
995-
label2 = tmp_label()
996-
output.append('or a')
997-
output.append('jr z, %s' % label2)
998999
output.append('%s:' % label)
9991000
output.append('add hl, hl')
10001001
output.append('djnz %s' % label)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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, 6
29+
.LABEL.__LABEL0:
30+
add hl, hl
31+
djnz .LABEL.__LABEL0
32+
.LABEL.__LABEL1:
33+
ld (_num2), hl
34+
ld hl, 0
35+
ld b, h
36+
ld c, l
37+
.core.__END_PROGRAM:
38+
di
39+
ld hl, (.core.__CALL_BACK__)
40+
ld sp, hl
41+
exx
42+
pop hl
43+
exx
44+
pop iy
45+
pop ix
46+
ei
47+
ret
48+
;; --- end of user code ---
49+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dim num1, num2 as integer
2+
num2 = num1 << 6

0 commit comments

Comments
 (0)