Skip to content

fix: crash on cast i32 to u32 #976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/arch/z80/backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ def to_long(stype: DataType) -> list[str]:
output.append("ld e, a")
output.append("ld d, a")

elif stype in (U32_t, I32_t):
return []

elif stype == U16_t:
output.append("ld de, 0")

Expand Down
42 changes: 42 additions & 0 deletions tests/functional/arch/zx48k/cast_i32tou32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
org 32768
.core.__START_PROGRAM:
di
push ix
push iy
exx
push hl
exx
ld (.core.__CALL_BACK__), sp
ei
jp .core.__MAIN_PROGRAM__
.core.__CALL_BACK__:
DEFW 0
.core.ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
_a:
DEFB 00, 00, 00, 00
.core.ZXBASIC_USER_DATA_END:
.core.__MAIN_PROGRAM__:
ld hl, (_a)
ld de, (_a + 2)
ld (_a), hl
ld (_a + 2), de
ld hl, 0
ld b, h
ld c, l
.core.__END_PROGRAM:
di
ld hl, (.core.__CALL_BACK__)
ld sp, hl
exx
pop hl
exx
pop iy
pop ix
ei
ret
;; --- end of user code ---
END
4 changes: 4 additions & 0 deletions tests/functional/arch/zx48k/cast_i32tou32.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DIM a as ULong

LET a = INT(a)