Skip to content

Commit 0310b77

Browse files
committed
fix: crash when converting some from byte to bool
1 parent 2e885fa commit 0310b77

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

src/arch/z80/backend/generic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ def _cast(ins: Quad):
341341

342342
xsB = sB = YY_TYPES[tB] # Type sizes
343343

344+
if tA in ("u8", "i8") and tB == "bool":
345+
return [] # bytes are booleans already (0 = False, not 0 = True)
346+
344347
output = []
345348
if tA in ("u8", "i8", "bool"):
346349
output.extend(Bits8.get_oper(ins[4]))
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
_pldx:
22+
DEFB 00
23+
.core.ZXBASIC_USER_DATA_END:
24+
.core.__MAIN_PROGRAM__:
25+
ld hl, 0
26+
ld b, h
27+
ld c, l
28+
.core.__END_PROGRAM:
29+
di
30+
ld hl, (.core.__CALL_BACK__)
31+
ld sp, hl
32+
exx
33+
pop hl
34+
exx
35+
pop iy
36+
pop ix
37+
ei
38+
ret
39+
_ReadKeys:
40+
push ix
41+
ld ix, 0
42+
add ix, sp
43+
pop af
44+
ld hl, (_pldx - 1)
45+
or h
46+
jp z, .LABEL.__LABEL1
47+
ld a, 1
48+
ld (_pldx), a
49+
.LABEL.__LABEL1:
50+
_ReadKeys__leave:
51+
ld sp, ix
52+
pop ix
53+
ret
54+
;; --- end of user code ---
55+
END
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dim pldx as ubyte
2+
3+
sub ReadKeys()
4+
if pldx or (pldx and %1) then
5+
pldx = 1
6+
endif
7+
end sub

0 commit comments

Comments
 (0)