fix: copy whole register on assignment
This commit is contained in:
@@ -161,15 +161,15 @@ object asmGenerator {
|
||||
labelGenerator: LabelGenerator
|
||||
): Chain[AsmLine] = {
|
||||
var asm = Chain.empty[AsmLine]
|
||||
asm += Comment(stmt.toString)
|
||||
stmt match {
|
||||
case Assign(lhs, rhs) =>
|
||||
lhs match {
|
||||
case ident: Ident =>
|
||||
if (!stack.contains(ident)) asm += stack.reserve(ident)
|
||||
val dest = Register(ident.ty.size, AX)
|
||||
asm ++= evalExprOntoStack(rhs)
|
||||
asm += stack.pop(RAX)
|
||||
asm += Move(stack.accessVar(ident), dest)
|
||||
asm += Move(stack.accessVar(ident).copy(opSize = Some(Size.Q64)), RAX)
|
||||
case ArrayElem(x, i) =>
|
||||
asm ++= evalExprOntoStack(rhs)
|
||||
asm ++= evalExprOntoStack(i)
|
||||
|
||||
Reference in New Issue
Block a user