Skip to content

Commit 8395008

Browse files
borielJose Rodriguez
authored andcommitted
fix: fix accessing Float local array
1 parent 7b39e82 commit 8395008

File tree

7 files changed

+1639
-11
lines changed

7 files changed

+1639
-11
lines changed

src/arch/z80/backend/_float.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _float_oper(op1, op2=None) -> list[str]:
4949
"""Returns pop sequence for floating point operands
5050
1st operand in A DE BC, 2nd operand remains in the stack
5151
52-
Unlike 8bit and 16bit version, this does not supports
52+
Unlike 8bit and 16bit version, this does not support
5353
operands inversion. Since many of the instructions are implemented
5454
as functions, they must support this.
5555
@@ -83,7 +83,7 @@ def _float_oper(op1, op2=None) -> list[str]:
8383
else:
8484
output.append("pop hl")
8585

86-
output.append(runtime_call(RuntimeLabel.ILOADF))
86+
output.append(runtime_call(RuntimeLabel.LOADF))
8787
else:
8888
if op[0] == "_":
8989
output.append("ld a, (%s)" % op)
@@ -94,7 +94,7 @@ def _float_oper(op1, op2=None) -> list[str]:
9494

9595
if op2 is not None:
9696
op = op1
97-
if is_float(op): # An float must be in the stack. Let's push it
97+
if is_float(op): # A float must be in the stack. Let's push it
9898
A, DE, BC = _float(op)
9999
output.append("ld hl, %s" % BC)
100100
output.append("push hl")

src/arch/z80/backend/_parray.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,10 @@ def _paload32(ins: Quad) -> list[str]:
102102

103103

104104
def _paloadf(ins: Quad) -> list[str]:
105-
"""Loads a floating point value from a memory address.
106-
If 2nd arg. start with '*', it is always treated as
107-
an indirect value.
108-
"""
105+
"""Loads a floating point value from a memory address."""
109106
output = _paddr(ins[2])
110-
output.append(runtime_call(RuntimeLabel.ILOADF))
107+
108+
output.append(runtime_call(RuntimeLabel.LOADF))
111109
output.extend(_fpush())
112110

113111
return output

src/arch/z80/visitor/translator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ def visit_ARRAYLOAD(self, node):
240240
t1 = optemps.new_t()
241241
t2 = optemps.new_t()
242242
t3 = optemps.new_t()
243-
self.ic_pload(gl.PTR_TYPE, t1, -(node.entry.offset - self.TYPE(gl.PTR_TYPE).size))
244-
self.ic_add(gl.PTR_TYPE, t2, t1, node.offset)
245-
self.ic_load(node.type_, t3, "*$%s" % t2)
243+
self.ic_pload(gl.PTR_TYPE, t1, -node.entry.offset + self.TYPE(gl.PTR_TYPE).size)
244+
self.ic_add(gl.PTR_TYPE, t2, t1, offset)
245+
self.ic_load(node.type_, t3, f"*${t2}")
246246

247247
def _emit_arraycopy_child(self, child: symbols.ID):
248248
assert child.token == "VARARRAY"

0 commit comments

Comments
 (0)