Ejemplo n.º 1
0
void SymVarConst::GenerateValue(AsmCode& asm_code) const
{
    if (value.GetType() == INT_CONST)
    {
        asm_code.AddCmd(ASM_PUSH, value.GetIntValue());
    }
    else if (value.GetType() == REAL_CONST)
    {
        stringstream s;
        s << value.GetName();
        float f;
        int* p = (int*)&f;
        s >> f;
        asm_code.AddCmd(ASM_PUSH, *p);
    }
Ejemplo n.º 2
0
void SymVarGlobal::Generate(AsmCode& asmCode, unsigned) const
{
   if (type->GetSize() > 4) {
      GenerateLValue(asmCode, 0);
      asmCode.PushMemory(type->GetSize());
   } else {
      asmCode.AddCmd(PUSH, AsmMemory(varLabel, 0, szDWORD));
   }
}
Ejemplo n.º 3
0
void SymProc::GenerateDeclaration(AsmCode& asm_code)
{
    if (IsDummyProc()) return;
    asm_code.AddLabel(label);
    asm_code.AddCmd(ASM_PUSH, REG_EBP);
    asm_code.AddCmd(ASM_MOV, REG_ESP, REG_EBP);
    if (sym_table->GetLocalsSize()) asm_code.AddCmd(ASM_SUB, sym_table->GetLocalsSize(), REG_ESP);
    body->Generate(asm_code);
    asm_code.AddLabel(exit_label);
    asm_code.AddCmd(ASM_MOV, REG_EBP, REG_ESP);
    asm_code.AddCmd(ASM_POP, REG_EBP);
    asm_code.AddCmd(ASM_RET, sym_table->GetParamsSize() - GetResultType()->GetSize());
}
Ejemplo n.º 4
0
void SymVarGlobal::GenerateLValue(AsmCode& asmCode, unsigned) const
{
   asmCode.AddCmd(PUSH, AsmVarAddr(varLabel));
}
Ejemplo n.º 5
0
void SymConstCharacterString::Generate(AsmCode& asmCode, unsigned stmtDepth) const
{
   asmCode.AddCmd(PUSH, AsmVarAddr(asmCode.AddData(asmCode.GenStrLabel("str"), value)));
}
Ejemplo n.º 6
0
void SymConstFloat::Generate(AsmCode& asmCode, unsigned) const
{
   asmCode.AddCmd(PUSH, constLabel);
}
Ejemplo n.º 7
0
void SymConstInteger::Generate(AsmCode& asmCode, unsigned) const
{
   asmCode.AddCmd(PUSH, value);
}