Skip to content
Snippets Groups Projects
Commit 9ea90dfe authored by ZaynouneFatimaZahrae's avatar ZaynouneFatimaZahrae
Browse files

sa2ts

parent bafe90e1
No related branches found
No related tags found
No related merge requests found
......@@ -47,8 +47,19 @@ public class Fg implements NasmVisitor <Void> {
}
public Void visit(NasmAdd inst){return null;}
public Void visit(NasmCall inst){return null;}
public Void visit(NasmAdd inst){
for(int i = 0; i < inst2Node.size();i++)
{
NasmInst nasmInst = nasm.sectionText.get(i);
if(nasmInst instanceof NasmAdd) {
}
}
return null;
}
public Void visit(NasmCall inst){
return null;
}
public Void visit(NasmDiv inst){return null;}
public Void visit(NasmJe inst){return null;}
public Void visit(NasmJle inst){return null;}
......
......@@ -46,16 +46,45 @@ public class C3a2nasm implements C3aVisitor <NasmOperand> {
return null;
}
public NasmOperand visit(C3aInstCall inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this):null;
NasmOperand addr = inst.result.accept(this);
nasm.ajouteInst(new NasmCall(label,addr,""));
return null;
}
private NasmOperand getLabelFromC3aInst(C3aInst inst) {
return new NasmLabel(inst.label.toString());
}
public NasmOperand visit(C3aInstFBegin inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this) : null;
nasm.ajouteInst(new NasmInst() {
@Override
void addLabel(String formatInst, NasmOperand label) {
super.addLabel(formatInst, label);
}
});
return null;
}
public NasmOperand visit(C3aInst inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this) : null;
NasmOperand addr = inst.label.accept(this);
NasmOperand destination = inst.label.accept(this);
NasmOperand source = inst.label.accept(this);
nasm.ajouteInst(new NasmInst() {
void addLabel(String formatInst, NasmOperand label) {
super.addLabel(formatInst, label);
}
});
return null;
}
public NasmOperand visit(C3aInstJumpIfLess inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this): null;
NasmOperand oper1 = inst.op1.accept(this);
NasmOperand oper2 = inst.op2.accept(this);
NasmOperand result = inst.result.accept(this);
nasm.ajouteInst(new NasmCmp(label,oper1,oper2,""));
nasm.ajouteInst(new NasmJle(null, result, ""));
return null;
}
public NasmOperand visit(C3aInst inst){return null;}
public NasmOperand visit(C3aInstJumpIfLess inst){return null;}
public NasmOperand visit(C3aInstMult inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this) : null;
nasm.ajouteInst(new NasmMov(label, inst.result.accept(this), inst.op1.accept(this),""));
......@@ -84,16 +113,34 @@ public class C3a2nasm implements C3aVisitor <NasmOperand> {
nasm.ajouteInst(new NasmSub(null, inst.result.accept(this), inst.op2.accept(this),""));
return null;
}
public NasmOperand visit(C3aInstAffect inst){return null;}
public NasmOperand visit(C3aInstAffect inst) {
NasmOperand label = (inst.label != null) ? inst.label.accept(this): null;
NasmOperand oper1 = inst.op1.accept(this);
NasmOperand result = inst.result.accept(this);
nasm.ajouteInst(new NasmMov(label, inst.result.accept(this), inst.op1.accept(this),""));
nasm.ajouteInst(new NasmInst() {
void addLabel(String formatInst, NasmOperand label) {
super.addLabel(formatInst, label);
}
});
return null;
}
// à revoir
public NasmOperand visit(C3aInstDiv inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this) : null;
nasm.ajouteInst(new NasmMov(label, inst.result.accept(this), inst.op1.accept(this),""));
//nasm.ajouteInst(new NasmDiv(null, inst.result.accept(this), inst.op2.accept(this),""));
nasm.ajouteInst(new NasmDiv(null, inst.result.accept(this), inst.op2.accept(this),""));
return null;
}
//à revoir
public NasmOperand visit(C3aInstFEnd inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this) : null;
nasm.ajouteInst(new NasmInst() {
void addLabel(String formatInst, NasmOperand label) {
super.addLabel(formatInst, label);
}
});
return null;
}
public NasmOperand visit(C3aInstJumpIfEqual inst){
......@@ -121,6 +168,8 @@ public class C3a2nasm implements C3aVisitor <NasmOperand> {
return null;
}
public NasmOperand visit(C3aInstParam inst){
NasmOperand label = (inst.label != null) ? inst.label.accept(this): null;
//nasm.ajouteInst(new NasmMov(label, ));
return null;
}
public NasmOperand visit(C3aInstReturn inst){
......
......@@ -8,6 +8,10 @@ public class NasmCall extends NasmInst {
this.comment = comment;
}
public NasmCall() {
}
public <T> T accept(NasmVisitor <T> visitor) {
return visitor.visit(this);
}
......
......@@ -9,6 +9,10 @@ public class NasmDiv extends NasmInst {
this.comment = comment;
}
public NasmDiv(Object label, NasmOperand accept, NasmOperand accept1, String s) {
super();
}
public <T> T accept(NasmVisitor <T> visitor) {
return visitor.visit(this);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment