diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/ASM.java b/src/main/java/de/hsrm/compiler/Klang/asm/ASM.java index 3e8e77f..c0d6909 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/ASM.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/ASM.java @@ -12,10 +12,6 @@ public class ASM { this.mnemonics = new ArrayList(); } - public void push(String operand) { - mnemonics.add(new Push(operand)); - } - public void push(String dataType, int immediate) { mnemonics.add(new Push(dataType, immediate)); } @@ -24,22 +20,10 @@ public class ASM { mnemonics.add(new Push(dataType, operand)); } - public void pop(String operand) { - mnemonics.add(new Pop(operand)); - } - public void pop(String dataType, String operand) { mnemonics.add(new Pop(dataType, operand)); } - public void mov(int immediate, String dst) { - mnemonics.add(new Mov(immediate, dst)); - } - - public void mov(String src, String dst) { - mnemonics.add(new Mov(src, dst)); - } - public void mov(String dataType, String src, String dst) { mnemonics.add(new Mov(dataType, src, dst)); } @@ -60,16 +44,12 @@ public class ASM { mnemonics.add(new Mov(dataType, immediate, dst)); } - public void ucomi(String src, String dst) { - mnemonics.add(new Ucomi(src, dst)); - } - public void ucomi(String dataType, String src, String dst) { mnemonics.add(new Ucomi(dataType, src, dst)); } - public void cmp(String src, String dst) { - mnemonics.add(new Cmp(src, dst)); + public void cmp(String dataType, String src, String dst) { + mnemonics.add(new Cmp(dataType, src, dst)); } public void cmp(String dataType, int immediate, String dst) { @@ -156,10 +136,6 @@ public class ASM { mnemonics.add(new Label(labelPrefix, label)); } - public void add(String src, String dst) { - mnemonics.add(new Add(src, dst)); - } - public void add(String dataType, String src, String dst) { mnemonics.add(new Add(dataType, src, dst)); } @@ -171,27 +147,15 @@ public class ASM { public void add(String dataType, int immediate, String dst) { mnemonics.add(new Add(dataType, immediate, dst)); } - - public void sub(String src, String dst) { - mnemonics.add(new Sub(src, dst)); - } public void sub(String dataType, String src, String dst) { mnemonics.add(new Sub(dataType, src, dst)); } - - public void mul(String src, String dst) { - mnemonics.add(new Mul(src, dst)); - } public void mul(String dataType, String src, String dst) { mnemonics.add(new Mul(dataType, src, dst)); } - public void div(String src, String dst) { - mnemonics.add(new Div(src, dst)); - } - public void div(String dataType, String src, String dst) { mnemonics.add(new Div(dataType, src, dst)); } @@ -200,12 +164,8 @@ public class ASM { mnemonics.add(new Idiv(dataType, operand)); } - public void idiv(String operand) { - mnemonics.add(new Idiv(operand)); - } - - public void imul(String src, String dst) { - mnemonics.add(new Imul(src, dst)); + public void imul(String dataType, String src, String dst) { + mnemonics.add(new Imul(dataType, src, dst)); } public void cqto() { @@ -219,10 +179,6 @@ public class ASM { public void xor(String dataType, String src, String dst) { mnemonics.add(new Xor(dataType, src, dst)); } - - public void xor(String src, String dst) { - mnemonics.add(new Xor(src, dst)); - } public void neg(String operand) { mnemonics.add(new Neg(operand)); diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Add.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Add.java index da69816..af6735c 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Add.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Add.java @@ -1,13 +1,8 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Add extends TwoOperandMnemonic { - public String dataType = "q"; - - public Add(String src, String dst) { - this.src = src; - this.dst = dst; - } - + public String dataType; + public Add(String dataType, String src, String dst) { this.dataType = dataType; this.src = src; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Cmp.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Cmp.java index 4ab5d3b..9868421 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Cmp.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Cmp.java @@ -1,9 +1,10 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Cmp extends TwoOperandMnemonic { - - public Cmp(String src, String dst) { - this.dataType = ""; + public String dataType; + + public Cmp(String dataType, String src, String dst) { + this.dataType = dataType; this.src = src; this.dst = dst; } diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Div.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Div.java index dfb72f0..051d317 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Div.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Div.java @@ -1,12 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Div extends TwoOperandMnemonic { - public String dataType = "q"; - - public Div(String src, String dst) { - this.src = src; - this.dst = dst; - } + public String dataType; public Div(String dataType, String src, String dst) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Idiv.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Idiv.java index 5aa776e..a642d34 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Idiv.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Idiv.java @@ -1,11 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Idiv extends OneOperandMnemonic{ - public String dataType = ""; - - public Idiv(String operand) { - this.operand = operand; - } + public String dataType; public Idiv(String dataType, String operand) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Imul.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Imul.java index 0e75e4a..4cab0b3 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Imul.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Imul.java @@ -1,9 +1,10 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Imul extends TwoOperandMnemonic { - public String dataType = "q"; + public String dataType; - public Imul(String src, String dst) { + public Imul(String dataType, String src, String dst) { + this.dataType = dataType; this.src = src; this.dst = dst; } diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mnemonic.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mnemonic.java index ce25776..8892c4d 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mnemonic.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mnemonic.java @@ -1,7 +1,6 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public abstract class Mnemonic { - public String dataType = ""; public abstract String toAsm(); public int indentation = 2; } \ No newline at end of file diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mov.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mov.java index 4a18870..1aca57c 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mov.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mov.java @@ -3,16 +3,6 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Mov extends TwoOperandMnemonic{ public String dataType = "q"; - public Mov(int immediate, String dst) { - this.src = "$" + immediate; - this.dst = dst; - } - - public Mov(String src, String dst) { - this.src = src; - this.dst = dst; - } - public Mov(String dataType, String src, String dst) { this.dataType = dataType; this.src = src; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mul.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mul.java index 5ff1038..d3bac9e 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mul.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Mul.java @@ -1,12 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Mul extends TwoOperandMnemonic { - public String dataType = "q"; - - public Mul(String src, String dst) { - this.src = src; - this.dst = dst; - } + public String dataType; public Mul(String dataType, String src, String dst) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Pop.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Pop.java index cf44583..a32a5e7 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Pop.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Pop.java @@ -1,10 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Pop extends OneOperandMnemonic { - public String dataType = "q"; - public Pop(String operand) { - this.operand = operand; - } + public String dataType; public Pop(String dataType, String operand) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Push.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Push.java index 12608ec..c6b0b30 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Push.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Push.java @@ -1,10 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Push extends OneOperandMnemonic { - public Push(String operand){ - this.dataType = "q"; - this.operand = operand; - } + public String dataType; public Push(String dataType, int immediate){ this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Sub.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Sub.java index 7b23345..7b14f65 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Sub.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Sub.java @@ -1,12 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Sub extends TwoOperandMnemonic { - public String dataType = "q"; - - public Sub(String src, String dst) { - this.src = src; - this.dst = dst; - } + public String dataType; public Sub(String dataType, String src, String dst) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Ucomi.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Ucomi.java index d3afa17..ac15c40 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Ucomi.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Ucomi.java @@ -1,12 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Ucomi extends TwoOperandMnemonic { - public String dataType = "q"; - - public Ucomi(String src, String dst) { - this.src = src; - this.dst = dst; - } + public String dataType; public Ucomi(String dataType, String src, String dst) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Xor.java b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Xor.java index 9989576..397c1eb 100644 --- a/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Xor.java +++ b/src/main/java/de/hsrm/compiler/Klang/asm/mnemonics/Xor.java @@ -1,12 +1,7 @@ package de.hsrm.compiler.Klang.asm.mnemonics; public class Xor extends TwoOperandMnemonic { - public String dataType = "q"; - - public Xor(String src, String dst) { - this.src = src; - this.dst = dst; - } + public String dataType; public Xor(String dataType, String src, String dst) { this.dataType = dataType; diff --git a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java index 8796f00..aad1f62 100644 --- a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java +++ b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java @@ -83,7 +83,7 @@ public class GenASM implements Visitor { asm.mov("sd", "%xmm0", "%xmm2"); rhs.welcome(this); asm.mov("sd", "%xmm2", "%xmm0"); - asm.mov("%xmm2", "%xmm0"); + asm.mov("sd", "%xmm2", "%xmm0"); return true; } else if (lhsIsFloat && !rhsIsFloat) { lhs.welcome(this); @@ -99,10 +99,10 @@ public class GenASM implements Visitor { return true; } else { lhs.welcome(this); - asm.push("%rax"); + asm.push("q", "%rax"); rhs.welcome(this); - asm.mov("%rax", "%rbx"); - asm.pop("%rax"); + asm.mov("q", "%rax", "%rbx"); + asm.pop("q", "%rax"); return false; } } @@ -123,7 +123,7 @@ public class GenASM implements Visitor { @Override public Void visit(IntegerExpression e) { - asm.mov(e.value, "%rax"); + asm.mov("q", e.value, "%rax"); return null; } @@ -136,7 +136,7 @@ public class GenASM implements Visitor { @Override public Void visit(BooleanExpression e) { - asm.mov(e.value ? 1 : 0, "%rax"); + asm.mov("q", e.value ? 1 : 0, "%rax"); return null; } @@ -159,15 +159,15 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.ucomi("sd", "%xmm1", "xmm0"); } else { - asm.cmp("%rbx", "%rax"); + asm.cmp("q", "%rbx", "%rax"); } asm.je(lblTrue); // false - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); asm.jmp(lblEnd); asm.label(lblTrue); // true - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.label(lblEnd); return null; } @@ -181,15 +181,15 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.ucomi("sd", "%xmm0", "%xmm1"); } else { - asm.cmp("%rax", "%rbx"); + asm.cmp("q", "%rax", "%rbx"); } asm.jne(lblTrue); // false - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); asm.jmp(lblEnd); asm.label(lblTrue); // true - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.label(lblEnd); return null; } @@ -203,15 +203,15 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.ucomi("sd", "%xmm1", "%xmm0"); } else { - asm.cmp("%rbx", "%rax"); + asm.cmp("q", "%rbx", "%rax"); } asm.jg(lblTrue); // false - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); asm.jmp(lblEnd); asm.label(lblTrue); // true - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.label(lblEnd); return null; } @@ -225,15 +225,15 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.ucomi("sd", "%xmm1", "xmm0"); } else { - asm.cmp("%rbx", "%rax"); + asm.cmp("q", "%rbx", "%rax"); } asm.jge(lblTrue); // false - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); asm.jmp(lblEnd); asm.label(lblTrue); // true - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.label(lblEnd); return null; } @@ -247,15 +247,15 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.ucomi("sd", "%xmm1", "%xmm0"); } else { - asm.cmp("%rbx", "%rax"); + asm.cmp("q", "%rbx", "%rax"); } asm.jl(lblTrue); // false - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); asm.jmp(lblEnd); asm.label(lblTrue); // true - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.label(lblEnd); return null; } @@ -269,15 +269,15 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.ucomi("sd", "%xmm1", "%xmm0"); } else { - asm.cmp("%rbx", "%rax"); + asm.cmp("q", "%rbx", "%rax"); } asm.jle(lblTrue); // false - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); asm.jmp(lblEnd); asm.label(lblTrue); // true - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.label(lblEnd); return null; } @@ -288,7 +288,7 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.add("sd", "%xmm1", "%xmm0"); } else { - asm.add("%rbx", "%rax"); + asm.add("q", "%rbx", "%rax"); } return null; } @@ -299,7 +299,7 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.sub("sd", "%xmm1", "%xmm0"); } else { - asm.sub("%rbx", "%rax"); + asm.sub("q", "%rbx", "%rax"); } return null; } @@ -310,7 +310,7 @@ public class GenASM implements Visitor { if (isFloatOperation) { asm.mul("sd", "%xmm1", "%xmm0"); } else { - asm.imul("%rbx", "%rax"); + asm.imul("q", "%rbx", "%rax"); } return null; } @@ -322,7 +322,7 @@ public class GenASM implements Visitor { asm.div("sd", "%xmm1", "%xmm0"); } else { asm.cqto(); - asm.idiv("%rbx"); + asm.idiv("q", "%rbx"); } return null; } @@ -330,13 +330,13 @@ public class GenASM implements Visitor { @Override public Void visit(ModuloExpression e) { e.lhs.welcome(this); - asm.push("%rax"); + asm.push("q", "%rax"); e.rhs.welcome(this); - asm.mov("%rax", "%rbx"); - asm.pop("%rax"); + asm.mov("q", "%rax", "%rbx"); + asm.pop("q", "%rax"); asm.cqto(); - asm.idiv("%rbx"); - asm.mov("%rdx", "%rax"); + asm.idiv("q", "%rbx"); + asm.mov("q", "%rdx", "%rax"); return null; } @@ -376,12 +376,12 @@ public class GenASM implements Visitor { // Die Expression wertet zu true aus // Springe am false Teil vorbei asm.label(lblTrue); - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.jmp(lblEnd); // Die Expressoin wertet zu false aus asm.label(lblFalse); - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); // Das hier ist das ende asm.label(lblEnd); @@ -411,12 +411,12 @@ public class GenASM implements Visitor { // Die Expression wertet zu true aus // Springe am false Teil vorbei asm.label(lblTrue); - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.jmp(lblEnd); // Die Expressoin wertet zu false aus asm.label(lblFalse); - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); // Das hier ist das ende asm.label(lblEnd); @@ -437,13 +437,13 @@ public class GenASM implements Visitor { // Hier ist das Ergebnis true // Springe am false Teil vorbei - asm.mov(1, "%rax"); + asm.mov("q", 1, "%rax"); asm.jmp(lblEnd); // Hier ist das Ergebnis false // Falle zum Ende durch asm.label(lblFalse); - asm.mov(0, "%rax"); + asm.mov("q", 0, "%rax"); // Hier ist das Ende asm.label(lblEnd); @@ -555,8 +555,8 @@ public class GenASM implements Visitor { @Override public Void visit(ReturnStatement e) { e.expression.welcome(this); - asm.mov("%rbp", "%rsp"); - asm.pop("%rbp"); + asm.mov("q", "%rbp", "%rsp"); + asm.pop("q", "%rbp"); asm.ret(); return null; } @@ -575,8 +575,8 @@ public class GenASM implements Visitor { this.currentFunctionStartLabel = lblStart; this.currentFunctionParams = e.parameters; asm.functionHead(e.name); - asm.push("%rbp"); - asm.mov("%rsp", "%rbp"); + asm.push("q", "%rbp"); + asm.mov("q", "%rsp", "%rbp"); asm.label(lblStart); // hole die anzahl der lokalen variablen @@ -623,13 +623,13 @@ public class GenASM implements Visitor { fi = 0; for (var param: registerParameters) { if (param.type.equals(Type.getFloatType())) { - asm.mov(this.floatRegisters[fi], "%rax"); - asm.push("%rax"); + asm.mov("q", this.floatRegisters[fi], "%rax"); + asm.push("q", "%rax"); offset -= 8; this.env.put(param.name, offset); // negative, liegt unter aktuellem BP fi++; } else { - asm.push(this.registers[ri]); + asm.push("q", this.registers[ri]); offset -= 8; this.env.put(param.name, offset); // negative, liegt unter aktuellem BP ri++; @@ -656,15 +656,15 @@ public class GenASM implements Visitor { e.arguments[i].welcome(this); if (e.arguments[i].type.equals(Type.getFloatType())) { - asm.mov("%xmm0", "%rax0"); + asm.mov("q", "%xmm0", "%rax0"); } - asm.push("%rax"); + asm.push("q", "%rax"); } // push args into local var locations, last arg is ontop of the stack for (int i = e.arguments.length - 1; i >= 0; i--) { - asm.pop(this.env.get(this.currentFunctionParams[i].name) + "(%rbp)"); + asm.pop("q", this.env.get(this.currentFunctionParams[i].name) + "(%rbp)"); } asm.jmp(this.currentFunctionStartLabel); @@ -713,10 +713,10 @@ public class GenASM implements Visitor { for (var arg : e.arguments) { arg.welcome(this); if (arg.type.equals(Type.getFloatType())) { - asm.mov("%xmm0", "%rax"); - asm.push("%rax"); + asm.mov("q", "%xmm0", "%rax"); + asm.push("q", "%rax"); } else { - asm.push("%rax"); + asm.push("q", "%rax"); } } @@ -760,11 +760,11 @@ public class GenASM implements Visitor { asm.newline(); } asm.functionHead(mainName); - asm.push("%rbp"); - asm.mov("%rsp", "%rbp"); + asm.push("q", "%rbp"); + asm.mov("q", "%rsp", "%rbp"); e.expression.welcome(this); - asm.mov("%rbp", "%rsp"); - asm.pop("%rbp"); + asm.mov("q", "%rbp", "%rsp"); + asm.pop("q", "%rbp"); asm.ret(); asm.text(fw.getFloatSection()); @@ -810,7 +810,7 @@ public class GenASM implements Visitor { // push rax to xmm0 if the result type is a float if (e.type.equals(Type.getFloatType())) { - asm.mov("%rax", "%xmm0"); + asm.mov("q", "%rax", "%xmm0"); } return null; @@ -824,10 +824,10 @@ public class GenASM implements Visitor { // move float values from xmm0 to rax first if (arg.type.equals(Type.getFloatType())) { - asm.mov("%xmm0", "%rax"); + asm.mov("q", "%xmm0", "%rax"); } - asm.push("%rax"); + asm.push("q", "%rax"); } // allocate heap memory by calling malloc @@ -837,7 +837,7 @@ public class GenASM implements Visitor { // push args into struct memory, last arg is ontop of the stack for (int i = e.args.length - 1; i >= 0; i--) { - asm.pop(Helper.getFieldOffset(structDef, i) + "(%rax)"); + asm.pop("q", Helper.getFieldOffset(structDef, i) + "(%rax)"); } return null; @@ -866,11 +866,11 @@ public class GenASM implements Visitor { // Move it from xmm0 rax if its a flaot if (e.expression.type.equals(Type.getFloatType())) { - asm.mov("%xmm0", "%rax"); + asm.mov("q", "%xmm0", "%rax"); } // Push the expression onto the stack - asm.push("%rax"); + asm.push("q", "%rax"); // move struct address into rax asm.mov("q", offset, "%rbp", "%rax"); @@ -883,7 +883,7 @@ public class GenASM implements Visitor { } // pop the expression that is ontop of the stack into the field of the struct that has to be updated - asm.pop(Helper.getFieldOffset(structDef, fieldNameToUpdate) + "(%rax)"); + asm.pop("q", Helper.getFieldOffset(structDef, fieldNameToUpdate) + "(%rax)"); asm.mov("q", 0 , "%rax"); // clear rax since an assignment has no result return null;