Skip to content

Commit 14662f5

Browse files
committed
fix: propagate SIGN in fixed to Long conversions
1 parent 223fede commit 14662f5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/arch/z80/backend/common.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,18 @@ def to_long(stype: DataType) -> list[str]:
402402
)
403403

404404
elif stype == F16_t:
405-
output.extend(["ex de, hl", "ld de, 0"])
405+
output.extend(
406+
[
407+
"ex de, hl",
408+
"ld de, 0",
409+
# Copies the highest bit (sign) to DE
410+
"ld a, h",
411+
"add a, a",
412+
"sbc a, a",
413+
"ld e, a",
414+
"ld d, a",
415+
]
416+
)
406417

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

0 commit comments

Comments
 (0)