public void EnterOffset(GBASMParser.OffsetContext context) { PrintLine("Offset"); SetArgLoc(Locations.OFFSET); LocationInfo l = GetCurrentArg(); l.isOffset = true; }
public void ExitString_data(GBASMParser.String_dataContext context) { //throw new NotImplementedException(); }
public void ExitTriad(GBASMParser.TriadContext context) { //throw new NotImplementedException(); }
public void ExitOp(GBASMParser.OpContext context) { PrintLine("End Op"); int starting_len = rom.Count; currentInst.AppendTo(rom); for(int i = starting_len; i < rom.Count; ++i) { MapByteToLine(context, i); } byteLines.Add(BuildByteString()); }
public void ExitRepblock(GBASMParser.RepblockContext context) { RepInfo r = rep_stack.Pop(); int romEnd = rom.Count; int lineEnd = lines.Count; if (context.Stop != null) { lines[lines.Count-1] += "; " + (inputStream.GetText(new Interval((int)context.Start.StartIndex, (int)context.Stop.StopIndex))); } else { lines[lines.Count-1] += "; " + (inputStream.GetText(new Interval((int)context.Start.StartIndex, (int)context.Start.StopIndex))); } while (r.reps > 0) { for (int index = r.linesStart; index < lineEnd; ++index ) { lines.Add(lines[index] + "; REPT" + index); byteLines.Add(byteLines[index]); } for (int index = r.romStart; index < romEnd; ++index) { RomPush(context, rom[index]); } r.reps--; } }
public void ExitLabel(GBASMParser.LabelContext context) { }
public void ExitNegvalue(GBASMParser.NegvalueContext context) { }
public void EnterSys(GBASMParser.SysContext context) { PrintLine("Starting Sys"); rom_ptr = rom.Count; }
public void EnterTriad(GBASMParser.TriadContext context) { PrintLine("Triad Detected"); argFSM = ArgFSM.SRC; currentInst.op = Instruction.MapOp(context.GetText()); }
public void EnterSection(GBASMParser.SectionContext context) { PrintLine("Starting Section"); if (context.Stop != null) { lines.Add(inputStream.GetText(new Interval((int)context.Start.StartIndex, (int)context.Stop.StopIndex))); } else { lines.Add(inputStream.GetText(new Interval((int)context.Start.StartIndex, (int)context.Start.StopIndex))); } isSectionArg = true; sec_stack.Push(new SectionInfo(rom.Count, lines.Count)); }
public void EnterString_data(GBASMParser.String_dataContext context) { PrintLine("Literal Value"); if (db_stack > 0) { String s = context.GetText(); //Remove quotations for (int i = 1; i < s.Length-1; ++i) { RomPush(context, (Byte)s[i]); } } }
public void EnterRepblock(GBASMParser.RepblockContext context) { //We do NOT support label resolution in rep blocks //Absolute labels MIGHT work isReptArg = true; rep_stack.Push(new RepInfo(rom.Count, lines.Count)); //Need to pad byteLines //byteLines.Add(""); }
public void EnterRegister(GBASMParser.RegisterContext context) { PrintLine("Register"); LocationInfo l = GetCurrentArg(); l.isReg = true; String target = context.GetText(); SetArgLoc(ParseLocation(target)); if(target == "HL+" || target == "HLI") { currentInst.op = Instructions.LDI; } if (target == "HL-" || target == "HLD") { currentInst.op = Instructions.LDD; } }
public void EnterOp(GBASMParser.OpContext context) { PrintLine("Start op"); rom_ptr = rom.Count; if ((context.Stop != null) && (context.Start.StartIndex < context.Stop.StopIndex)) { lines.Add(inputStream.GetText(new Interval(context.Start.StartIndex, context.Stop.StopIndex))); } else { lines.Add(inputStream.GetText(new Interval(context.Start.StartIndex, context.Start.StopIndex))); } currentInst = new Instruction(); }
public void ExitInclude(GBASMParser.IncludeContext context) { //throw new NotImplementedException(); }
public void EnterValue(GBASMParser.ValueContext context) { PrintLine("Numeric Value"); String s = context.GetText(); PrintLine(s); Int16 value = (Int16)ParseNum(s); if (isReptArg) { isReptArg = false; rep_stack.Peek().reps = value-1; //Offset for the fact the original code will be copied } else if (isSectionArg) { isSectionArg = false; sec_stack.Peek().size = value; } else { if (db_stack > 0) { RomPush(context, (Byte)value); } else { if (Math.Abs(value) > 255) { SetArgLoc(Locations.WIDE_IMM); } else { SetArgLoc(Locations.IMM); } SetArgVal(value); } } }
public void ExitJump(GBASMParser.JumpContext context) { }
public void ExitArg(GBASMParser.ArgContext context) { DecArg(); }
public void ExitMemory(GBASMParser.MemoryContext context) { }
public void ExitData(GBASMParser.DataContext context) { db_stack -= 1; PrintLine("DB at " + db_stack.ToString()); }
public void ExitOffset(GBASMParser.OffsetContext context) { }
public void ExitDb(GBASMParser.DbContext context) { //throw new NotImplementedException(); }
public void ExitRegister(GBASMParser.RegisterContext context) { }
public void ExitEval(GBASMParser.EvalContext context) { PrintLine("Finished"); }
public void ExitSection(GBASMParser.SectionContext context) { //Use Label Buf SectionInfo info = sec_stack.Pop(); int distance_req = info.size - rom.Count; for(int i = 0; i < distance_req; ++i) { RomPush(context, 0x00); } byteLines.Add(BuildByteString()); }
public void ExitExp(GBASMParser.ExpContext context) { PrintLine("End Exp"); }
public void ExitSys(GBASMParser.SysContext context) { PrintLine("Ending Sys"); //MapByteToLine(rom.Count, context.Start.Line); }
public void ExitFlag(GBASMParser.FlagContext context) { }
public void ExitValue(GBASMParser.ValueContext context) { }
public void EnterNegvalue(GBASMParser.NegvalueContext context) { PrintLine("Signed Value"); Int16 value = (Int16)(-ParseNum(context.GetText().Substring(1))); if (db_stack > 0) { RomPush(context, (Byte)value); } else { if (Math.Abs(value) > 127) { SetArgLoc(Locations.WIDE_IMM); } else { SetArgLoc(Locations.IMM); } SetArgVal(value); } }