Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request boriel-basic#691 from boriel/bugfix/local_array_of…
Browse files Browse the repository at this point in the history
…_floats

fix: fix accessing Float local array
  • Loading branch information
boriel committed Nov 24, 2023
2 parents 7b39e82 + 8395008 commit 427a64a
Show file tree
Hide file tree
Showing 7 changed files with 1,639 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/arch/z80/backend/_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _float_oper(op1, op2=None) -> list[str]:
"""Returns pop sequence for floating point operands
1st operand in A DE BC, 2nd operand remains in the stack
Unlike 8bit and 16bit version, this does not supports
Unlike 8bit and 16bit version, this does not support
operands inversion. Since many of the instructions are implemented
as functions, they must support this.
Expand Down Expand Up @@ -83,7 +83,7 @@ def _float_oper(op1, op2=None) -> list[str]:
else:
output.append("pop hl")

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

if op2 is not None:
op = op1
if is_float(op): # An float must be in the stack. Let's push it
if is_float(op): # A float must be in the stack. Let's push it
A, DE, BC = _float(op)
output.append("ld hl, %s" % BC)
output.append("push hl")
Expand Down
8 changes: 3 additions & 5 deletions src/arch/z80/backend/_parray.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,10 @@ def _paload32(ins: Quad) -> list[str]:


def _paloadf(ins: Quad) -> list[str]:
"""Loads a floating point value from a memory address.
If 2nd arg. start with '*', it is always treated as
an indirect value.
"""
"""Loads a floating point value from a memory address."""
output = _paddr(ins[2])
output.append(runtime_call(RuntimeLabel.ILOADF))

output.append(runtime_call(RuntimeLabel.LOADF))
output.extend(_fpush())

return output
Expand Down
6 changes: 3 additions & 3 deletions src/arch/z80/visitor/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def visit_ARRAYLOAD(self, node):
t1 = optemps.new_t()
t2 = optemps.new_t()
t3 = optemps.new_t()
self.ic_pload(gl.PTR_TYPE, t1, -(node.entry.offset - self.TYPE(gl.PTR_TYPE).size))
self.ic_add(gl.PTR_TYPE, t2, t1, node.offset)
self.ic_load(node.type_, t3, "*$%s" % t2)
self.ic_pload(gl.PTR_TYPE, t1, -node.entry.offset + self.TYPE(gl.PTR_TYPE).size)
self.ic_add(gl.PTR_TYPE, t2, t1, offset)
self.ic_load(node.type_, t3, f"*${t2}")

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

0 comments on commit 427a64a

Please sign in to comment.