예제 #1
0
 // A signed (two's complement) 8-bit offset (-128 to 127) relative to the first byte of the following instruction.
 private static bool o(uint uInstr, i8051Disassembler dasm)
 {
     if (!dasm.rdr.TryReadByte(out byte b))
     {
         return(false);
     }
     dasm.ops.Add(AddressOperand.Create(dasm.rdr.Address + (sbyte)b));
     return(true);
 }
예제 #2
0
 // A direct addressed bit in internal data RAM or SFR memory.
 private static bool B(uint uInstr, i8051Disassembler dasm)
 {
     if (!dasm.rdr.TryReadByte(out byte b))
     {
         return(false);
     }
     dasm.ops.Add(dasm.BitReg(b, true));
     return(true);
 }
예제 #3
0
 // An internal data RAM location (0-127) or SFR (128-255).
 private static bool d(uint uInstr, i8051Disassembler dasm)
 {
     if (!dasm.rdr.TryReadByte(out byte b))
     {
         return(false);
     }
     dasm.ops.Add(MemoryOperand.Direct(Address.Ptr16(b)));
     return(true);
 }
예제 #4
0
 // A 16-bit address destination. This argument is used by LCALL and LJMP instructions.
 private static bool J(uint uInstr, i8051Disassembler dasm)
 {
     if (!dasm.rdr.TryReadBeUInt16(out var uAddr)) // Yes, big endian!
     {
         return(false);
     }
     dasm.ops.Add(AddressOperand.Ptr16(uAddr));
     return(true);
 }
예제 #5
0
 // A constant included in the instruction encoding.
 private static bool i(uint uInstr, i8051Disassembler dasm)
 {
     if (!dasm.rdr.TryReadByte(out byte b))
     {
         return(false);
     }
     dasm.ops.Add(ImmediateOperand.Byte(b));
     return(true);
 }
예제 #6
0
        // A constant included in the instruction encoding.
        private static bool I(uint uInstr, i8051Disassembler dasm)
        {
            if (!dasm.rdr.TryReadUInt16(out var w))
            {
                return(false);
            }

            dasm.ops.Add(ImmediateOperand.Word16(w));
            return(true);
        }
예제 #7
0
        // An internal data RAM location (0-127) or SFR (128-255).
        private static bool d(uint uInstr, i8051Disassembler dasm)
        {
            if (!dasm.rdr.TryReadByte(out byte b))
            {
                return(false);
            }
            var offset = Constant.UInt16(b);

            offset.DataType = PrimitiveType.Offset16;
            dasm.ops.Add(MemoryOperand.Direct(offset));
            return(true);
        }
예제 #8
0
 // An 11-bit address destination. This argument is used by ACALL and AJMP instructions. The target of the CALL or JMP must lie within the same 2K page as the first byte of the following instruction.
 private static bool j(uint uInstr, i8051Disassembler dasm)
 {
     if (!dasm.rdr.TryReadByte(out byte b))
     {
         return(false);
     }
     dasm.ops.Add(AddressOperand.Ptr16(
                      (ushort)(
                          (dasm.rdr.Address.ToLinear() & ~0x7Ful) |
                          (uInstr & 0xE0u) << 3 |
                              b)));
     return(true);
 }
예제 #9
0
 public override i8051Instruction Decode(uint op, i8051Disassembler dasm)
 {
     foreach (var m in mutators)
     {
         if (!m(op, dasm))
         {
             return(dasm.CreateInvalidInstruction());
         }
     }
     return(new i8051Instruction
     {
         Mnemonic = opcode,
         Address = dasm.addr,
         Length = (int)(dasm.rdr.Address - dasm.addr),
         Operands = dasm.ops.ToArray()
     });
 }
예제 #10
0
 public override i8051Instruction Decode(byte op, i8051Disassembler dasm)
 {
     foreach (var m in mutators)
     {
         if (!m(op, dasm))
         {
             return(dasm.CreateInvalidInstruction());
         }
     }
     return(new i8051Instruction
     {
         Opcode = opcode,
         Address = dasm.addr,
         Length = (int)(dasm.rdr.Address - dasm.addr),
         Operand1 = dasm.ops.Count >= 1 ? dasm.ops[0] : null,
         Operand2 = dasm.ops.Count >= 2 ? dasm.ops[1] : null,
         Operand3 = dasm.ops.Count >= 3 ? dasm.ops[2] : null,
     });
 }
예제 #11
0
 // Register r0-r7
 private static bool r(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(dasm.Reg((int)uInstr & 7));
     return(true);
 }
예제 #12
0
 // @A + PC:
 private static bool P(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(MemoryOperand.Indexed(Registers.PC, Registers.A));
     return(true);
 }
예제 #13
0
 // AB register pair
 private static bool AB(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(new SequenceOperand(Registers.AB));
     return(true);
 }
예제 #14
0
 public abstract i8051Instruction Decode(byte op, i8051Disassembler dasm);
예제 #15
0
 // @Ri	An internal data RAM location (0-255) addressed indirectly through R0 or R1.
 private static bool Ind(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(MemoryOperand.Indirect(Registers.GetRegister((int)uInstr & 1)));
     return(true);
 }
예제 #16
0
 public override i8051Instruction Decode(byte op, i8051Disassembler dasm)
 {
     return(dasm.Decode(opcode, op, fmt));
 }
예제 #17
0
 // @DPTR
 private static bool D(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(MemoryOperand.Indirect(Registers.DPTR));
     return(true);
 }
예제 #18
0
 // C flag of PSW
 private static bool C(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(new FlagGroupOperand(Registers.CFlag));
     return(true);
 }
예제 #19
0
 // The accumulator.
 private static bool A(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(new RegisterOperand(Registers.A));
     return(true);
 }
예제 #20
0
 // C flag of PSW
 private static bool C(uint uInstr, i8051Disassembler dasm)
 {
     dasm.ops.Add(new FlagGroupOperand(dasm.arch.GetFlagGroup((uint)FlagM.C)));
     return(true);
 }