Example #1
0
        private bool SetTag(bool isAlias = false)
        {
            for (int i = 0; i < codelist.Count; i++)
            {
                codelist[i].Alias = isAlias;
                codelist[i].Validate();
                if (codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.BEQ)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg3) /*/4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return(false);
                    }

                    _tag.Name        = Convert.ToString(taglist.Count);              //use counter as name
                    codelist[i].Arg3 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else if (codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.BNE)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg3) /*/ 4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return(false);
                    }

                    _tag.Name        = Convert.ToString(taglist.Count);              //use counter as name
                    codelist[i].Arg3 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else if (codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.J)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg1) /*/ 4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return(false);
                    }

                    _tag.Name        = Convert.ToString(taglist.Count);              //use counter as name
                    codelist[i].Arg1 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else if (codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.JAL)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg1) /*/ 4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return(false);
                    }

                    _tag.Name        = Convert.ToString(taglist.Count);              //use counter as name
                    codelist[i].Arg1 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else
                {
                }
            }
            return(true);
        }
Example #2
0
        private bool SetTag(bool isAlias = false)
        {
            for(int i = 0; i<codelist.Count; i++)
            {
                codelist[i].Alias = isAlias;
                codelist[i].Validate();
                if(codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.BEQ)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg3)/*/4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return false;
                    }

                    _tag.Name = Convert.ToString(taglist.Count);                     //use counter as name
                    codelist[i].Arg3 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else if(codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.BNE)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg3) /*/ 4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return false;
                    }

                    _tag.Name = Convert.ToString(taglist.Count);                     //use counter as name
                    codelist[i].Arg3 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else if(codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.J)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg1) /*/ 4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return false;
                    }

                    _tag.Name = Convert.ToString(taglist.Count);                     //use counter as name
                    codelist[i].Arg1 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else if(codelist[i].Mnemonic == MIPS246.Core.DataStructure.Mnemonic.JAL)
                {
                    tag _tag = new tag();
                    _tag.Pos = Convert.ToInt32(codelist[i].Arg1) /*/ 4*/ + i;

                    if (_tag.Pos < 0 || _tag.Pos > codelist.Count)
                    {
                        /*error code*/
                        this.error = new DisassemblerErrorInfo(i, AssemblerError.WRONGTAG, "jump target OutOfBounds");
                        return false;
                    }

                    _tag.Name = Convert.ToString(taglist.Count);                     //use counter as name
                    codelist[i].Arg1 = "tag" + _tag.Name;
                    taglist.Add(_tag);
                }
                else
                {
                }
            }
            return true;
        }