internal static bool TryParse(string ASMLine, ASMLine Current, out ASMLine Out) { Out = null; ASMLine = ASMLine.ToLower().Trim(); string[] split = null; if (ASMLine.Length < 1) { return(false); //empty line } if (ASMLine[0] == ';') { return(false); //comment line, end of section } //section headers if ((split = ASMLine.Split(':')).Length > 1 && Regex.IsMatch(split[0], "^[a-z_0-9]+$")) { return((Out = new SectionHeader(split[0])) != null); } split = SPR.Split(ASMLine); switch (split[0]) { case "nop": return((Out = new NOP(Current)) != null); case "movzx": return((Out = new MOVZX(Current, split)) != null); case "cmp": return((Out = new CMP(Current, split)) != null); case "jnb": case "jbe": case "jmp": return((Out = new JUMP(Current, split)) != null); case "retn": return((Out = new RET(Current)) != null); default: throw new NotImplementedException($"Unable to parse instruction {split[0]}"); } }
public override void Eval(ref char[] Stack, ref char EDX, ref char EAX, ref Stack <ASMLine> CallStack) { Action = SolveAction.Eval; if (To.Contains("die")) //oshit { CallStack.Pop(); //this JUMP PrevJump = null; while ((PrevJump = CallStack.Peek() as JUMP) == null) { CallStack.Pop().Action = SolveAction.Eval; if (CallStack.Count < 1) { Action = SolveAction.JumpStart; CallStack.Push(this); return; } } PrevJump.TrySolve(ref Stack, ref CallStack); } else { var _cmp = (Previous as CMP); //hope this never turns out bad thonkers if (Type == JumpType.jmp || (!_cmp.CF) == (Type == JumpType.jnb)) { CallStack.Push(ASM_Map[To]); } else { CallStack.Push(Next); } } }
private void TranslateStm(JUMP stm) { InstrList.Add(new Jump(new Label(stm.Targets.Head))); }
void PrintStm(JUMP s, int d) { Indent(d); SayLn("JUMP("); PrintExp(s.Exp, d + 1); Say(")"); }