Skip to content
Snippets Groups Projects
Commit 642e15ce authored by ZaynouneFatimaZahrae's avatar ZaynouneFatimaZahrae
Browse files

sa2ts

parent ad1c7593
Branches
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
......
......@@ -10,6 +10,7 @@ public class C3a2nasm implements C3aVisitor <NasmOperand> {
private TsItemFct currentFct;
private NasmRegister esp;
private NasmRegister ebp;
private NasmLabel label;
public C3a2nasm(C3a c3a, Ts tableGlobale){
......@@ -30,30 +31,83 @@ public class C3a2nasm implements C3aVisitor <NasmOperand> {
public NasmOperand visit(C3a c3a){return null;}
public NasmOperand visit(C3aInstAdd inst){return null;}
public NasmOperand visit(C3aInstAdd 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 NasmAdd(null,
inst.result.accept(this),
inst.op2.accept(this), ""));
return null;
}
public NasmOperand visit(C3aInstCall inst){return null;}
public NasmOperand visit(C3aInstFBegin inst){return null;}
public NasmOperand visit(C3aInst inst){return null;}
public NasmOperand visit(C3aInstJumpIfLess inst){return null;}
public NasmOperand visit(C3aInstMult inst){return null;}
public NasmOperand visit(C3aInstRead inst){return null;}
public NasmOperand visit(C3aInstSub 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),""));
nasm.ajouteInst(new NasmMul(null, inst.result.accept(this), inst.op2.accept(this),""));
return null;
}
public NasmOperand visit(C3aInstRead inst){
nasm.ajouteInst(new NasmMov ((inst),
nasm.newRegister(),
new NasmLabel("sinput"), ""));
nasm.ajouteInst(new NasmCall(null,
new NasmLabel("readline"), ""));
nasm.ajouteInst(new NasmCall(null,
new NasmLabel("atoi"), ""));
nasm.ajouteInst(new NasmMov (null,
inst.result.accept(this),
nasm.newRegister() , ""));
return null;
}
public NasmOperand visit(C3aInstSub 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 NasmSub(null, inst.result.accept(this), inst.op2.accept(this),""));
return null;
}
public NasmOperand visit(C3aInstAffect inst){return null;}
public NasmOperand visit(C3aInstDiv inst){return null;}
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),""));
return null;
}
public NasmOperand visit(C3aInstFEnd inst){return null;}
public NasmOperand visit(C3aInstJumpIfEqual inst){return null;}
public NasmOperand visit(C3aInstJumpIfNotEqual inst){return null;}
public NasmOperand visit(C3aInstJump inst){return null;}
public NasmOperand visit(C3aInstParam inst){return null;}
public NasmOperand visit(C3aInstReturn inst){return null;}
public NasmOperand visit(C3aInstWrite inst){return null;}
public NasmOperand visit(C3aInstStop inst){return null;}
public NasmOperand visit(C3aInstWrite inst){
nasm.ajouteInst(new NasmMov (getLabelFromC3aInst(inst),
nasm.newRegister(),
inst.op1.accept(this), ""));
nasm.ajouteInst(new NasmCall(null,
new NasmLabel("iprintLF"), ""));
return null;
}
public NasmOperand visit(C3aInstStop inst){
return null;
}
public NasmOperand visit(C3aConstant oper){return null;}
public NasmOperand visit(C3aBooleanConstant oper){return null;}
public NasmOperand visit(C3aLabel oper){return null;}
public NasmOperand visit(C3aTemp oper){return null;}
public NasmOperand visit(C3aLabel oper){
return new NasmLabel("l" + label.val);
}
public NasmOperand visit(C3aTemp oper){
return new NasmRegister(oper.num);
}
public NasmOperand visit(C3aVar oper){return null;}
public NasmOperand visit(C3aFunction oper){return null;}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment