private void ILDataEnd(QuadTuple qt) { DataSegment.Add(".code"); }
private void ILVarDefine(QuadTuple qt) { var tplt = "{0} {1} {2}"; var vtype = qt.LValue.ValueType; var name = qt.LValue.ID; if (vtype == "int") { if (isLocal) { if (!LSymbols.ContainsKey(name)) { var tplt_local = " local {0}:{1}"; LSymbols[name] = vtype; ProcSegment.Insert(0, string.Format(tplt_local, name, "dword")); } if (qt.RValueA is not null) { if (qt.RValueA.ILNameType == ILNameType.Constant) { var tplt1 = " mov {0},{1}"; ProcSegment.Add(string.Format(tplt1, name, qt.RValueA.ID)); } else { var tplt1 = " mov eax,{0}"; var tplt2 = " mov {0},eax"; if (qt.RValueA.ValueType == "addr") { ProcSegment.Add(string.Format(tplt1, "dword ptr " + qt.RValueA.ID)); } else { ProcSegment.Add(string.Format(tplt1, qt.RValueA.ID)); } ProcSegment.Add(string.Format(tplt2, name)); } } else { ProcSegment.Add(string.Format(" mov {0},0", name)); } } else { GSymbols[name] = vtype; if (qt.RValueA is not null) { if (qt.RValueA.ILNameType == ILNameType.Constant) { var tplt1 = " mov {0},{1}"; ProcSegment.Add(string.Format(tplt1, name, qt.RValueA.ID)); } else { var tplt1 = " mov eax,{0}"; var tplt2 = " mov {0},eax"; if (qt.RValueA.ValueType == "addr") { ProcSegment.Add(string.Format(tplt1, "dword ptr " + qt.RValueA.ID)); } else { ProcSegment.Add(string.Format(tplt1, qt.RValueA.ID)); } ProcSegment.Add(string.Format(tplt2, name)); } } else { DataSegment.Add(string.Format(tplt, name, "dword", 0)); } } } else if (vtype == "string") { GSymbols[name] = "string"; var tplt1 = "{0} byte {1},0"; var str = qt.RValueA.ID; if (str.Length >= 4 && str[str.Length - 3] == '\\' && str[str.Length - 2] == 'n') { str = str.Remove(str.Length - 3, 2); if (str.Length <= 2) { DataSegment.Add(string.Format(tplt1, name, "0ah")); } else { DataSegment.Add(string.Format(tplt1, name, str + ",0ah")); } } else { DataSegment.Add(string.Format(tplt1, name, str)); } } }
private void ILDataBegin(QuadTuple qt) { DataSegment.Add(".data"); }