Esempio n. 1
0
        // source register (5 bits)
        private static bool r(uint wInstr, Avr8Disassembler dasm)
        {
            var iReg = (int)((wInstr >> 4) & 0x10 | (wInstr >> 4) & 0x0F);

            dasm.ops.Add(dasm.Register(iReg));
            return(true);
        }
Esempio n. 2
0
        // Relative jump
        private static bool J(uint wInstr, Avr8Disassembler dasm)
        {
            int offset = (short)((wInstr & 0xFFF) << 4);

            offset = offset >> 3;
            dasm.ops.Add(AddressOperand.Create(dasm.addr + 2 + offset));
            return(true);
        }
Esempio n. 3
0
 // Trailing 16-bit absolute address
 private static bool w(uint uInstr, Avr8Disassembler dasm)
 {
     if (!dasm.rdr.TryReadLeUInt16(out ushort w2))
     {
         return(false);
     }
     dasm.ops.Add(AddressOperand.Ptr16(w2));
     return(true);
 }
Esempio n. 4
0
            public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
            {
                int slot = (wInstr >> shift) & mask;

                if (!decoders.TryGetValue(slot, out Decoder decoder))
                {
                    return(invalid.Decode(dasm, wInstr));
                }
                return(decoder.Decode(dasm, wInstr));
            }
Esempio n. 5
0
        // Branch offset
        private static bool o(uint wInstr, Avr8Disassembler dasm)
        {
            short offset;

            offset = (short)wInstr;
            offset = (short)(offset << 6);
            offset = (short)(offset >> 8);
            offset = (short)(offset & ~1);
            dasm.ops.Add(AddressOperand.Create(dasm.addr + offset + 2));
            return(true);
        }
Esempio n. 6
0
            public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
            {
                int   slot = (wInstr >> shift) & mask;
                OpRec oprec;

                if (!oprecs.TryGetValue(slot, out oprec))
                {
                    return(dasm.Decode(wInstr, Opcode.invalid, InstrClass.Invalid, ""));
                }
                return(oprec.Decode(dasm, wInstr));
            }
Esempio n. 7
0
            public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
            {
                int br = (((wInstr >> 7) & 8) | (wInstr & 7)) & 0xF;

                o(wInstr, dasm);
                return(new AvrInstruction
                {
                    iclass = InstrClass.ConditionalTransfer,
                    opcode = branches[br],
                    operands = dasm.ops.ToArray()
                });
            }
Esempio n. 8
0
 // absolute address used by jump and call.
 private static bool Q(uint wInstr, Avr8Disassembler dasm)
 {
     if (!dasm.rdr.TryReadLeUInt16(out ushort w2))
     {
         return(false);
     }
     dasm.ops.Add(AddressOperand.Ptr32(
                      (uint)(((wInstr >> 4) & 0x1F) << 18) |
                      (uint)((wInstr & 1) << 17) |
                      (uint)(w2 << 1)));
     return(true);
 }
Esempio n. 9
0
 public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
 {
     foreach (var m in mutators)
     {
         if (!m(wInstr, dasm))
         {
             return(invalid.Decode(dasm, wInstr));
         }
     }
     return(new AvrInstruction
     {
         opcode = opcode,
         iclass = iclass,
         operands = dasm.ops.ToArray(),
     });
 }
Esempio n. 10
0
            public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
            {
                int slot = (wInstr >> shift) & mask;

                return(oprecs[slot].Decode(dasm, wInstr));
            }
Esempio n. 11
0
 public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
 {
     return(dasm.Decode(wInstr, opcode, iclass, fmt));
 }
Esempio n. 12
0
 public abstract AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr);
Esempio n. 13
0
 // Destination register
 private static bool D(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(dasm.Register(((int)wInstr >> 4) & 0x1F));
     return(true);
 }
Esempio n. 14
0
 private static bool z(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(dasm.MemD(Avr8Architecture.z, dasm.Displacement((ushort)wInstr)));
     return(true);
 }
Esempio n. 15
0
 private static bool Z(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(dasm.MemD(Avr8Architecture.z, 0));
     return(true);
 }
Esempio n. 16
0
 // source register (r16-r31)
 private static bool r4(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(dasm.Register(0x10 | (int)wInstr & 0x0F));
     return(true);
 }
Esempio n. 17
0
 // immediate used by adiw/sbiw
 private static bool s(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(ImmediateOperand.Byte((byte)(((wInstr >> 2) & 0x30) | (wInstr & 0xF))));
     return(true);
 }
Esempio n. 18
0
 // register pair used by adiw
 private static bool q(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(dasm.Register(24 + ((int)(wInstr >> 3) & 6)));
     return(true);
 }
Esempio n. 19
0
 // register pair source
 private static bool P(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(dasm.Register(((int)wInstr << 1) & ~1));
     return(true);
 }
Esempio n. 20
0
            public override AvrInstruction Decode(Avr8Disassembler dasm, ushort wInstr)
            {
                int br = (((wInstr >> 7) & 8) | (wInstr & 7)) & 0xF;

                return(dasm.Decode(wInstr, branches[br], InstrClass.ConditionalTransfer, "o"));
            }
Esempio n. 21
0
 // 4-bit immediate at bit 0
 private static bool I(uint wInstr, Avr8Disassembler dasm)
 {
     dasm.ops.Add(ImmediateOperand.Byte((byte)(wInstr & 0x0F)));
     return(true);
 }