Skip to content

Commit 4a82c62

Browse files
committed
fix: cast f16 to long or ulong was broken
1 parent 8fb788e commit 4a82c62

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/arch/z80/backend/common.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,24 @@ def to_long(stype: DataType) -> list[str]:
385385
)
386386
return output
387387

388-
if stype in {I8_t, U8_t, F16_t}: # Byte to word
388+
if stype in (I8_t, U8_t): # Byte to word
389389
output = to_word(stype)
390+
output.append("ld e, h")
391+
output.append("ld d, h")
390392

391-
if stype != F16_t: # If it's a byte, just copy H to D,E
392-
output.append("ld e, h")
393-
output.append("ld d, h")
393+
elif stype == I16_t: # Signed byte or fixed to word
394+
output.extend(
395+
[
396+
"ld a, h",
397+
"add a, a",
398+
"sbc a, a",
399+
"ld e, a",
400+
"ld d, a",
401+
]
402+
)
394403

395-
elif stype in (I16_t, F16_t): # Signed byte or fixed to word
396-
output.append("ld a, h")
397-
output.append("add a, a")
398-
output.append("sbc a, a")
399-
output.append("ld e, a")
400-
output.append("ld d, a")
404+
elif stype == F16_t:
405+
output.extend(["ex de, hl", "ld de, 0"])
401406

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

0 commit comments

Comments
 (0)