Пример #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);
    }
Пример #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));
   }
}
Пример #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());
}
Пример #4
0
void SymVarGlobal::GenerateLValue(AsmCode& asmCode, unsigned) const
{
   asmCode.AddCmd(PUSH, AsmVarAddr(varLabel));
}
Пример #5
0
void SymConstCharacterString::Generate(AsmCode& asmCode, unsigned stmtDepth) const
{
   asmCode.AddCmd(PUSH, AsmVarAddr(asmCode.AddData(asmCode.GenStrLabel("str"), value)));
}
Пример #6
0
void SymConstFloat::Generate(AsmCode& asmCode, unsigned) const
{
   asmCode.AddCmd(PUSH, constLabel);
}
Пример #7
0
void SymConstInteger::Generate(AsmCode& asmCode, unsigned) const
{
   asmCode.AddCmd(PUSH, value);
}