public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { foreach (var m in mutators) { if (!m(b, dasm)) { return new Tlcs900Instruction { Opcode = Opcode.invalid, iclass = iclass, Address = dasm.addr } } ; } var instr = new Tlcs900Instruction { Opcode = opcode, iclass = iclass, Address = dasm.addr, op1 = dasm.ops.Count > 0 ? dasm.ops[0] : null, op2 = dasm.ops.Count > 1 ? dasm.ops[1] : null, op3 = dasm.ops.Count > 2 ? dasm.ops[2] : null, }; return(instr); } }
public override Tlcs900Instruction Decode(uint bPrev, Tlcs900Disassembler dasm) { if (!mutator(bPrev, dasm) || !dasm.rdr.TryReadByte(out byte b)) { return(dasm.CreateInvalidInstruction()); } return(memDecoders[b].Decode(b, dasm)); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { if (!mutator(b, dasm) || !dasm.rdr.TryReadByte(out b)) { return(dasm.Invalid()); } return(memOpRecs[b].Decode(b, dasm)); }
public override Tlcs900Instruction Decode(uint b, Tlcs900Disassembler dasm) { return(new Tlcs900Instruction { Mnemonic = dasm.opSize !.Size == 2 ? Mnemonic.ldirw : Mnemonic.ldir, InstructionClass = InstrClass.Linear, Operands = new MachineOperand[0], Address = dasm.addr });
// Relative jump private static bool jb(uint b, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadByte(out byte o8)) { return(false); } dasm.ops.Add(AddressOperand.Create(dasm.rdr.Address + (sbyte)o8)); return(true); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { dasm.opSrc = dasm.DecodeOperand(b, this.fmt); if (dasm.opSrc == null || !dasm.rdr.TryReadByte(out b)) { return(dasm.Decode(b, Opcode.invalid, "")); } return(memOpRecs[b].Decode(b, dasm)); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { return(new Tlcs900Instruction { Opcode = dasm.opSize.Size == 2 ? Opcode.ldirw : Opcode.ldir, iclass = InstrClass.Linear, Address = dasm.addr }); }
// immediate private static bool Ib(uint u, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadByte(out byte b)) { return(false); } dasm.ops.Add(ImmediateOperand.Byte(b)); return(true); }
private static bool Iw(uint u, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadLeUInt16(out ushort w)) { return(false); } dasm.ops.Add(ImmediateOperand.Word16(w)); return(true); }
private static bool Ix(uint u, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadLeUInt32(out u)) { return(false); } dasm.ops.Add(ImmediateOperand.Word32(u)); return(true); }
private static bool jw(uint b, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadLeInt16(out short o16)) { return(false); } dasm.ops.Add(AddressOperand.Create(dasm.rdr.Address + o16)); return(true); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { if (dasm.opSize == 'w') { return(dasm.Decode(b, Opcode.ldirw, "")); } else { return(dasm.Decode(b, Opcode.ldir, "")); } }
private static bool Jl(uint b, Tlcs900Disassembler dasm) { var dst = dasm.AbsoluteDestination(3); if (dst is null) { return(false); } dasm.ops.Add(dst); return(true); }
private static bool C(uint b, Tlcs900Disassembler dasm) { // condition code var cc = (CondCode)(b & 0xF); if (cc != CondCode.T) { dasm.ops.Add(new ConditionOperand(cc)); } return(true); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { dasm.opDst = dasm.DecodeOperand(b, this.fmt); if (dasm.opDst == null) { return(dasm.Decode(b, Opcode.invalid, "")); } return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = dasm.opSrc, op2 = dasm.opDst, }); }
private static bool Iz(uint u, Tlcs900Disassembler dasm) { if (dasm.opSize == null) { return(false); } switch (dasm.opSize.Size) { case 1: return(Ib(u, dasm)); case 2: return(Iw(u, dasm)); case 4: return(Ix(u, dasm)); } return(false); }
public override Tlcs900Instruction Decode(uint b, Tlcs900Disassembler dasm) { foreach (var m in mutators) { if (!m(b, dasm)) { return(dasm.CreateInvalidInstruction()); } } dasm.ops.Reverse(); return(new Tlcs900Instruction { Mnemonic = this.mnemonic, Address = dasm.addr, Operands = dasm.ops.ToArray() }); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadByte(out b)) { return(null); } dasm.opSize = width[0]; dasm.opSrc = dasm.ExtraRegister(b, width); if (dasm.opSrc == null) { return(null); } if (!dasm.rdr.TryReadByte(out b)) { return(null); } return(regOpRecs[b].Decode(b, dasm)); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { if (!mutator(b, dasm) || !dasm.rdr.TryReadByte(out b)) { return(dasm.Invalid()); } var instr = dstOpRecs[b].Decode(b, dasm); if (instr.op1 != null && instr.op2 != null) { instr.op1.Width = instr.op2.Width; } if (instr.op2 != null && instr.op2.Width == null) { //$HACK to get conditional calls/jumps to work instr.op2.Width = PrimitiveType.Word32; } return(instr); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { foreach (var m in mutators) { if (!m(b, dasm)) { return(dasm.Invalid()); } } bool swap = dasm.ops.Count == 2; return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = swap ? dasm.ops[1] : dasm.ops[0], op2 = swap ? dasm.ops[0] : null }); }
public override Tlcs900Instruction Decode(uint b, Tlcs900Disassembler dasm) { foreach (var m in mutators) { if (!m(b, dasm)) { return(dasm.CreateInvalidInstruction()); } } var instr = new Tlcs900Instruction { Mnemonic = opcode, InstructionClass = iclass, Address = dasm.addr, Operands = dasm.ops.ToArray() }; return(instr); }
public override Tlcs900Instruction Decode(uint bPrev, Tlcs900Disassembler dasm) { if (!mutator(bPrev, dasm) || !dasm.rdr.TryReadByte(out byte b)) { return(dasm.CreateInvalidInstruction()); } var instr = dstDecoders[b].Decode(b, dasm); if (instr.Operands.Length >= 2) { instr.Operands[0].Width = instr.Operands[1].Width; } if (instr.Operands.Length >= 2 && instr.Operands[1].Width == null) { //$HACK to get conditional calls/jumps to work instr.Operands[1].Width = PrimitiveType.Word32; } return(instr); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { dasm.opSrc = dasm.DecodeOperand(b, this.fmt); if (dasm.opSrc == null || !dasm.rdr.TryReadByte(out b)) { return(dasm.Decode(b, Opcode.invalid, "")); } var instr = dstOpRecs[b].Decode(b, dasm); if (instr.op1 != null && instr.op2 != null) { instr.op1.Width = instr.op2.Width; } if (instr.op2 != null && instr.op2.Width == null) { //$HACK to get conditional calls/jumps to work instr.op2.Width = PrimitiveType.Word32; } return(instr); }
public override Tlcs900Instruction Decode(uint bPrev, Tlcs900Disassembler dasm) { if (!dasm.rdr.TryReadByte(out byte b)) { return(null); } dasm.opSize = width; var op = dasm.ExtraRegister(b); if (op == null) { return(dasm.CreateInvalidInstruction()); } if (!dasm.rdr.TryReadByte(out b)) { return(dasm.CreateInvalidInstruction()); } dasm.ops.Add(op); return(regDecoders[b].Decode(b, dasm)); }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { if (this.fmt.Length == 0) { return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = dasm.opSrc }); } if (this.fmt[0] == 'Z') { // Override the size of opSrc dasm.opSrc.Width = dasm.Size(fmt[1]); return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = dasm.opSrc, }); } else { dasm.opDst = dasm.DecodeOperand(b, this.fmt); if (dasm.opDst == null) { return(dasm.Decode(b, Opcode.invalid, "")); } return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = dasm.opDst, op2 = dasm.opSrc, }); } }
public override Tlcs900Instruction Decode(byte b, Tlcs900Disassembler dasm) { if (this.mutator == null) { return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = dasm.ops[0] }); } if (!mutator(b, dasm)) { return(dasm.Invalid()); } return(new Tlcs900Instruction { Opcode = this.opcode, Address = dasm.addr, op1 = dasm.ops.Count > 1 ? dasm.ops[1] : dasm.ops[0], op2 = dasm.ops.Count > 1 ? dasm.ops[0] : null, }); }
public override Tlcs900Instruction Decode(uint bPrev, Tlcs900Disassembler dasm) { if (this.mutator == null) { return(new Tlcs900Instruction { Mnemonic = this.mnemonic, Address = dasm.addr, Operands = dasm.ops.ToArray() }); } if (!mutator(bPrev, dasm)) { return(dasm.CreateInvalidInstruction()); } dasm.ops.Reverse(); return(new Tlcs900Instruction { Mnemonic = this.mnemonic, Address = dasm.addr, Operands = dasm.ops.ToArray() }); }
private static bool BW(uint b, Tlcs900Disassembler dasm) { // Opsize must be set to byte or word16. return(dasm.opSize.Size == 1 || dasm.opSize.Size == 2); }
private static bool Sw(uint b, Tlcs900Disassembler dasm) { dasm.ops.Add(new RegisterOperand(Tlcs900Registers.sr)); return(true); }
private static bool Jl(uint b, Tlcs900Disassembler dasm) { dasm.ops.Add(dasm.AbsoluteDestination(3)); return(true); }