Exemplo n.º 1
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            int code = memory[offset];

            if ((code & 0xF8) == 0x58)
            {
                // 01011rrr
                cmd.Attributes = new string[] { RAsm.Reg32Name(code & 0x03) };
                return(true);
            }
            else if (code == 0x9C)
            {
                // 10001111oo000mmm
                return(true);
            }
            else if ((code & 0xC7) == 0x07)
            {
                // 00sss111
                cmd.Attributes = new string[] { RAsm.RegSssName((code & 0x38) >> 3) };
                return(true);
            }
            else if (code == 0x0F)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0xC7) == 0x81)
                {
                    // 0000 1111 10ss s001
                    cmd.Size       = 2;
                    cmd.Attributes = new string[] { RAsm.RegSssName((code2 & 0x38) >> 3) };
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            byte code = memory[offset];

            if ((code & 0xF8) == 0x40)
            {
                // 01000rrr
                cmd.Attributes = new string[] { RAsm.Reg32Name(code & 0x03) };
                return(true);
            }
            else if ((code & 0xFE) == 0xFE)
            {
                // 1111111woo000mmm
                cmd.Size = 2;
                int    code2 = memory[offset + 1];
                int    w     = code & 0x01;
                int    oo    = (code2 & 0xC0) >> 6;
                int    rrr   = (code2 & 0x38) >> 3;
                int    mmm   = (code2 & 0x07);
                string p1    = RAsm.RegName(w, rrr);
                string p2    = RAsm.FuncName(w, oo, mmm);
                cmd.Attributes = new string[] { p1, p2 };
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public override bool Parse(FAsmCommand command, FBytes memory, int offset)
        {
            int code = memory[offset];

            if ((code & 0xF8) == 0x50)
            {
                // 0101 0rrr - RegWord
                command.Attributes = new string[] { RAsm.Reg32Name(code & 0x07) };
                return(true);
            }
            else if (code == 0xFF)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x30)
                {
                    // 1111 1111 oo11 0mmm - MemWord
                    command.Size = 2;
                    int oo = (code2 & 0xC0) >> 6;
                    command.Attributes = new string[] { RAsm.FuncName(1, oo, code2 & 0x07) };
                    return(true);
                }
            }
            else if ((code & 0xC7) == 0x06)
            {
                // 00ss s110 - SegOld
                int sss = (code & 0x38) >> 3;
                command.Attributes = new string[] { RAsm.RegSssName(sss) };
                return(true);
            }
            else if (code == 0x0F)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0xC7) == 0x80)
                {
                    // 0000 1111 10ss s000 - Seg
                    command.Size = 2;
                    int sss = (code & 0x38) >> 3;
                    command.Attributes = new string[] { RAsm.RegSssName(sss) };
                    return(true);
                }
            }
            else if ((code & 0x6A) == 0x6A)
            {
                // 01101010 - Imm8
                command.Size       = 1 + RAsm.W0_BYTES;
                command.Attributes = new string[] { memory[offset + 1].ToString("X2") };
                return(true);
            }
            else if ((code & 0x68) == 0x68)
            {
                // 01101000 - Imm
                command.Size       = 1 + RAsm.W1_BYTES;
                command.Attributes = new string[] { memory.GetUint32(offset + 1).ToString("X8") };
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            byte code = memory[offset++];

            if ((code & 0xFE) == 0x02)
            {
                // 0000 001w oorrrmmm
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(code & 0x01, memory[offset + 1]);
                return(true);
            }
            else if ((code & 0xFE) == 0x00)
            {
                // 0000 000w oorrrmmm
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(code & 0x01, memory[offset + 1]);
                return(true);
            }
            else if ((code & 0xFE) == 0x04)
            {
                // 0000010w
                if ((code & 0x01) == 0x00)
                {
                    cmd.Size       = 1 + RAsm.W0_BYTES;
                    cmd.Attributes = new string[] { memory[offset + 1].ToString("X2") };
                }
                else
                {
                    cmd.Size       = 1 + RAsm.W1_BYTES;
                    cmd.Attributes = new string[] { memory.GetUint32(offset + 1).ToString("X8") };
                }
                return(true);
            }
            else if ((code & 0xFE) == 0x82)
            {
                int code2 = memory[offset++];
                if ((code2 & 0x38) == 0x00)
                {
                    // 1000 001w oo00 0mmm
                    cmd.Size = 2;
                    RAsm.ParseOoMmm(cmd, code & 0x01, (code2 & 0xC0) >> 6, code2 & 0x07, memory, offset);
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x80)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x00)
                {
                    // 1000 000w oo000mmm
                    cmd.Size = 2;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 5
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            byte code = memory[offset];

            if (code == 0x8D)
            {
                // 1000 1101 oorr rmmm
                cmd.Size = 2;
                return(RAsm.ParseOoRrrMmm(cmd, 1, memory[offset + 1], memory, offset + 2));
            }
            return(false);
        }
Exemplo n.º 6
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            byte code = memory[offset];

            if (code == 0x63)
            {
                // 0110 0011 oorrrmmm
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(1, memory[offset + 1]);
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            byte code = memory[offset];

            if ((code & 0xFE) == 0x2A)
            {
                // 0010 101w oorr rmmm - Reg,Reg
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(code & 0x01, memory[offset + 1]);
                return(true);
            }
            else if ((code & 0xFE) == 0x28)
            {
                // 0010 100w oorr rmmm - Mem,Reg
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(code & 0x01, memory[offset + 1]);
                return(true);
            }
            else if ((code & 0xFE) == 0x2C)
            {
                // 0010 110w - Acc,Imm
                cmd.Size = 1;
                return(true);
            }
            else if ((code & 0xFE) == 0x82)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x28)
                {
                    // 1000 001w oo10 1mmm - Reg,Imm8
                    cmd.Size = 2;
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x80)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x28)
                {
                    // 1000 000w oo10 1mmm - Reg,Imm
                    cmd.Size = 2 + RAsm.GetWordBytes(code & 0x01);
                    int    oo  = (code2 & 0xC0) >> 6;
                    string des = RAsm.FuncName(code & 0x01, oo, code2 & 0x07);
                    cmd.Attributes = new object[] { des, memory.GetUint32(offset + 2) };
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        public override bool Parse(FAsmCommand cmd, FBytes memory, int offset)
        {
            byte code = memory[offset];

            if ((code & 0xFE) == 0x12)
            {
                // 0001 001w oorr rmmm
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(code & 0x01, memory[offset + 1]);
                return(true);
            }
            else if ((code & 0xFE) == 0x10)
            {
                // 0001 000w oorr rmmm
                cmd.Size       = 2;
                cmd.Attributes = RAsm.OoRrrMmmName(code & 0x01, memory[offset + 1]);
                return(true);
            }
            else if ((code & 0xFE) == 0x14)
            {
                // 0001 010w
                cmd.Size = 1;
                return(true);
            }
            else if ((code & 0xFE) == 0x82)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x10)
                {
                    // 1000 001w oo01 0mmm
                    cmd.Size = 2;
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x80)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x10)
                {
                    // 1000 000w oo01 0mmm
                    cmd.Size = 2;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 9
0
        public override bool Parse(FAsmCommand command, FBytes memory, int offset)
        {
            int code = memory[offset];

            if ((code & 0xFE) == 0xA2)
            {
                // 1010 001w - MemOfs,Acc
                return(true);
            }
            else if ((code & 0xFE) == 0xA0)
            {
                // 1010 000w - Acc,MemOfs
                command.Size       = 1 + RInt.BYTE_SIZE;
                command.Attributes = new object[] { "EAX", "dword ptr [" + memory.GetUint32(offset + 1).ToString("X8") + "]" };
                return(true);
            }
            else if ((code & 0xF0) == 0xB0)
            {
                // 1011 wrrr - Reg,Imm
                offset++;
                int w = (code & 0x08) >> 3;
                if (w == 0x01)
                {
                    command.Size       = 1 + RInt.BYTE_SIZE;
                    command.Attributes = new object[] { RAsm.RegName(w, code & 0x07), memory.GetUint32(offset) };
                }
                else
                {
                    command.Size       = 1 + RByte.BYTE_SIZE;
                    command.Attributes = new object[] { RAsm.RegName(w, code & 0x07), memory[offset] };
                }
                return(true);
            }
            else if ((code & 0xFE) == 0xC6)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x00)
                {
                    // 1100 011w oo00 0mmm - Reg,Reg
                    command.Size = 2;
                    int w  = code & 0x01;
                    int oo = (code2 & 0xC0) >> 6;
                    command.Attributes = new string[] { RAsm.FuncName(w, oo, code2 & 0x07) };
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x8A)
            {
                // 1000 101w oorr rmmm
                int code2 = memory[offset + 1];
                command.Size = 2;
                int    w   = code & 0x01;
                int    oo  = (code2 & 0xC0) >> 6;
                string des = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string src = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if ((code & 0xFE) == 0x8A)
            {
                // 1000 101w oorr rmmm - Reg,Mem
                int code2 = memory[offset + 1];
                int w     = code & 0x01;
                int oo    = (code2 & 0xC0) >> 6;
                if (oo == 0x01)
                {
                    command.Size = 3;
                }
                else
                {
                    command.Size = 2;
                }
                string src = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string des = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if ((code & 0xFE) == 0x88)
            {
                // 1000 100w oorr rmmm - Mem,Reg
                int code2 = memory[offset + 1];
                int w     = code & 0x01;
                int oo    = (code2 & 0xC0) >> 6;
                if (oo == 0x01)
                {
                    command.Size = 3;
                }
                else
                {
                    command.Size = 2;
                }
                string src = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string des = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if (code == 0x8C)
            {
                // 1000 1100 oosssmmm - Reg16,Seg
                int code2 = memory[offset + 1];
                int w     = code & 0x01;
                int oo    = (code2 & 0xC0) >> 6;
                if (oo == 0x01)
                {
                    command.Size = 3;
                }
                else
                {
                    command.Size = 2;
                }
                string src = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string des = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if (code == 0x8E)
            {
                // 1000 1110 ooss smmm - Seg,Reg16
                int code2 = memory[offset + 1];
                int w     = code & 0x01;
                int oo    = (code2 & 0xC0) >> 6;
                if (oo == 0x01)
                {
                    command.Size = 3;
                }
                else
                {
                    command.Size = 2;
                }
                string src = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string des = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if (code == 0x8C)
            {
                // 1000 1100 ooss smmm - Mem16,Seg
                int code2 = memory[offset + 1];
                int w     = code & 0x01;
                int oo    = (code2 & 0xC0) >> 6;
                if (oo == 0x01)
                {
                    command.Size = 3;
                }
                else
                {
                    command.Size = 2;
                }
                string src = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string des = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if (code == 0x8E)
            {
                // 1000 1110 ooss smmm - Seg,Mem16
                int code2 = memory[offset + 1];
                int w     = code & 0x01;
                int oo    = (code2 & 0xC0) >> 6;
                if (oo == 0x01)
                {
                    command.Size = 3;
                }
                else
                {
                    command.Size = 2;
                }
                string src = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string des = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if (code == 0x0F)
            {
                int code2 = memory[offset + 1];
                if (code2 == 0x20)
                {
                    int code3 = memory[offset + 2];
                    if ((code3 & 0xC0) == 0xC0)
                    {
                        // 0000 1111 0010 0000 11ss srrr - CRn,Reg32
                        command.Size = 3;
                        string des = RAsm.RegSssName((code3 & 0x38) >> 3);
                        string src = RAsm.Reg32Name(code3 & 0x07);
                        command.Attributes = new string[] { des, src };
                        return(true);
                    }
                }
                else if (code2 == 0x22)
                {
                    int code3 = memory[offset + 2];
                    if ((code3 & 0xC0) == 0xC0)
                    {
                        // 0000 1111 0010 0010 11ss srrr
                        command.Size = 3;
                        string des = RAsm.RegSssName((code3 & 0x38) >> 3);
                        string src = RAsm.Reg32Name(code3 & 0x07);
                        command.Attributes = new string[] { des, src };
                        return(true);
                    }
                }
                else if (code2 == 0x21)
                {
                    int code3 = memory[offset + 2];
                    if ((code3 & 0xC0) == 0xC0)
                    {
                        // 0000 1111 0010 0001 11ss srrr - Reg32,DRn
                        command.Size = 3;
                        string des = RAsm.Reg32Name(code3 & 0x07);
                        string src = RAsm.RegSssName((code3 & 0x38) >> 3);
                        command.Attributes = new string[] { des, src };
                        return(true);
                    }
                }
                else if (code2 == 0x23)
                {
                    int code3 = memory[offset + 2];
                    if ((code3 & 0xC0) == 0xC0)
                    {
                        // 0000 1111 0010 0011 11ss srrr - DRn,Reg32
                        command.Size = 3;
                        string src = RAsm.Reg32Name(code3 & 0x07);
                        string des = RAsm.RegSssName((code3 & 0x38) >> 3);
                        command.Attributes = new string[] { des, src };
                        return(true);
                    }
                }
                else if (code2 == 0x24)
                {
                    int code3 = memory[offset + 2];
                    if ((code3 & 0xC0) == 0xC0)
                    {
                        // 0000 1111 0010 0100 11ss srrr - Reg32,TRn
                        command.Size = 3;
                        string src = RAsm.Reg32Name(code3 & 0x07);
                        string des = RAsm.RegSssName((code3 & 0x38) >> 3);
                        command.Attributes = new string[] { des, src };
                        return(true);
                    }
                }
                else if (code2 == 0x26)
                {
                    int code3 = memory[offset + 2];
                    if ((code3 & 0xC0) == 0xC0)
                    {
                        // 0000 1111 0010 0110 11ss srrr - TRn,Reg32
                        command.Size = 3;
                        string src = RAsm.Reg32Name(code3 & 0x07);
                        string des = RAsm.RegSssName((code3 & 0x38) >> 3);
                        command.Attributes = new string[] { des, src };
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 10
0
        public override bool Parse(FAsmCommand command, FBytes memory, int offset)
        {
            int code = memory[offset];

            if ((code & 0xFE) == 0x34)
            {
                // 0011 010w - Acc,Imm
                return(true);
            }
            else if ((code & 0xFE) == 0x32)
            {
                // 0011 001w oorr rmmm - Reg,Reg
                //33 C5            xor         eax,ebp
                command.Size = 2;
                int    code2 = memory[offset + 1];
                int    w     = code & 0x01;
                int    oo    = (code2 & 0xC0) >> 6;
                string des   = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string src   = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if ((code & 0xFE) == 0x30)
            {
                // 0011 000w oorr rmmm - Mem,Reg
                command.Size = 2;
                int    code2 = memory[offset + 1];
                int    w     = code & 0x01;
                int    oo    = (code2 & 0xC0) >> 6;
                string des   = RAsm.RegName(w, (code2 & 0x38) >> 3);
                string src   = RAsm.FuncName(w, oo, code2 & 0x07);
                command.Attributes = new string[] { des, src };
                return(true);
            }
            else if ((code & 0xFE) == 0x32)
            {
                // 0011 001w oor rrmmm - Reg,Mem
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x30)
                {
                    command.Size = 2;
                    int    w   = code & 0x01;
                    int    oo  = (code2 & 0xC0) >> 6;
                    string des = RAsm.Reg32Name((code2 & 0x38) >> 3);
                    string src = RAsm.FuncName(w, oo, code2 & 0x07);
                    command.Attributes = new string[] { des, src };
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x82)
            {
                // 1000 001w oo11 0mmm - Reg,Imm8
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x30)
                {
                    command.Size = 2;
                    int    w   = code & 0x01;
                    int    oo  = (code2 & 0xC0) >> 6;
                    string des = RAsm.Reg32Name((code2 & 0x38) >> 3);
                    string src = RAsm.FuncName(w, oo, code2 & 0x07);
                    command.Attributes = new string[] { des, src };
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x82)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x30)
                {
                    // 1000 001w oo11 0mmm - Mem,Imm8
                    command.Size = 2;
                    int    w   = code & 0x01;
                    int    oo  = (code2 & 0xC0) >> 6;
                    string des = RAsm.Reg32Name((code2 & 0x38) >> 3);
                    string src = RAsm.FuncName(w, oo, code2 & 0x07);
                    command.Attributes = new string[] { des, src };
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x80)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x30)
                {
                    // 1000 000w oo11 0mmm - Reg,Imm
                    command.Size = 2;
                    int    w   = code & 0x01;
                    int    oo  = (code2 & 0xC0) >> 6;
                    string des = RAsm.Reg32Name((code2 & 0x38) >> 3);
                    string src = RAsm.FuncName(w, oo, code2 & 0x07);
                    command.Attributes = new string[] { des, src };
                    return(true);
                }
            }
            else if ((code & 0xFE) == 0x80)
            {
                int code2 = memory[offset + 1];
                if ((code2 & 0x38) == 0x30)
                {
                    // 1000 000w oo11 0mmm - Mem,Imm
                    command.Size = 2;
                    int    w   = code & 0x01;
                    int    oo  = (code2 & 0xC0) >> 6;
                    string des = RAsm.Reg32Name((code2 & 0x38) >> 3);
                    string src = RAsm.FuncName(w, oo, code2 & 0x07);
                    command.Attributes = new string[] { des, src };
                    return(true);
                }
            }
            return(false);
        }