Esempio n. 1
0
 public void EnterOffset(GBASMParser.OffsetContext context)
 {
     PrintLine("Offset");
     SetArgLoc(Locations.OFFSET);
     LocationInfo l = GetCurrentArg();
     l.isOffset = true;
 }
Esempio n. 2
0
 public void ExitString_data(GBASMParser.String_dataContext context)
 {
     //throw new NotImplementedException();
 }
Esempio n. 3
0
 public void ExitTriad(GBASMParser.TriadContext context)
 {
     //throw new NotImplementedException();
 }
Esempio n. 4
0
 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());
 }
Esempio n. 5
0
        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--;
            }
        }
Esempio n. 6
0
 public void ExitLabel(GBASMParser.LabelContext context)
 {
 }
Esempio n. 7
0
 public void ExitNegvalue(GBASMParser.NegvalueContext context)
 {
 }
Esempio n. 8
0
 public void EnterSys(GBASMParser.SysContext context)
 {
     PrintLine("Starting Sys");
     rom_ptr = rom.Count;
 }
Esempio n. 9
0
 public void EnterTriad(GBASMParser.TriadContext context)
 {
     PrintLine("Triad Detected");
     argFSM = ArgFSM.SRC;
     currentInst.op = Instruction.MapOp(context.GetText());
 }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
 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]);
         }
     }
 }
Esempio n. 12
0
 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("");
 }
Esempio n. 13
0
 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;
     }
 }
Esempio n. 14
0
 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();
 }
Esempio n. 15
0
 public void ExitInclude(GBASMParser.IncludeContext context)
 {
     //throw new NotImplementedException();
 }
Esempio n. 16
0
        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);
                }
            }
        }
Esempio n. 17
0
 public void ExitJump(GBASMParser.JumpContext context)
 {
 }
Esempio n. 18
0
 public void ExitArg(GBASMParser.ArgContext context)
 {
     DecArg();
 }
Esempio n. 19
0
 public void ExitMemory(GBASMParser.MemoryContext context)
 {
 }
Esempio n. 20
0
        public void ExitData(GBASMParser.DataContext context)
        {
            db_stack -= 1;

            PrintLine("DB at " + db_stack.ToString());
        }
Esempio n. 21
0
 public void ExitOffset(GBASMParser.OffsetContext context)
 {
 }
Esempio n. 22
0
 public void ExitDb(GBASMParser.DbContext context)
 {
     //throw new NotImplementedException();
 }
Esempio n. 23
0
 public void ExitRegister(GBASMParser.RegisterContext context)
 {
 }
Esempio n. 24
0
 public void ExitEval(GBASMParser.EvalContext context)
 {
     PrintLine("Finished");
 }
Esempio n. 25
0
 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());
 }
Esempio n. 26
0
 public void ExitExp(GBASMParser.ExpContext context)
 {
     PrintLine("End Exp");
 }
Esempio n. 27
0
 public void ExitSys(GBASMParser.SysContext context)
 {
     PrintLine("Ending Sys");
     //MapByteToLine(rom.Count, context.Start.Line);
 }
Esempio n. 28
0
 public void ExitFlag(GBASMParser.FlagContext context)
 {
 }
Esempio n. 29
0
 public void ExitValue(GBASMParser.ValueContext context)
 {
 }
Esempio n. 30
0
        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);
            }
        }