public byte[] Encode() { if (!Decoded) { throw new InvalidOperationException(); } var bw = new BitWriter(); bw.WriteBits((int)Condition, 28, 4); // Condition switch (Multiplication) { case EMultiplication.Mul: bw.WriteBits((int)Rd, 16, 4); break; case EMultiplication.Mla: bw.WriteBits(1, 21, 1); bw.WriteBits((int)Rd, 16, 4); bw.WriteBits((int)Rn, 12, 4); break; case EMultiplication.Smlal: bw.WriteBits(1, 21, 1); goto case EMultiplication.Smull; case EMultiplication.Smull: bw.WriteBits(1, 23, 1); bw.WriteBits(1, 22, 1); bw.WriteBits((int)RdHi, 16, 4); bw.WriteBits((int)RdLo, 12, 4); break; case EMultiplication.Umlal: bw.WriteBits(1, 21, 1); goto case EMultiplication.UMull; case EMultiplication.UMull: bw.WriteBits(1, 23, 1); bw.WriteBits((int)RdHi, 16, 4); bw.WriteBits((int)RdLo, 12, 4); break; default: throw new ArgumentOutOfRangeException(); } bw.WriteBits((int)Rs, 8, 4); bw.WriteBits(1, 7, 1); bw.WriteBits(1, 4, 1); bw.WriteBits((int)Rm, 0, 4); return(bw.GetValue()); }
public byte[] Encode() { if (!Decoded) { throw new InvalidOperationException(); } var bw = new BitWriter(); bw.WriteBits((int)Condition, 28, 4); // Condition if (Operand2 == EOperand2.RotateImmediate) { bw.WriteBits(1, 25, 1); } bw.WriteBits((int)Opcode, 21, 4); // Opcode bw.WriteBits(SetConditionFlags ? 1 : 0, 20, 1); // Set condition flags bw.WriteBits((int)Rn, 16, 4); // Rn bw.WriteBits((int)Rd, 12, 4); // Rd // Operand2 switch (Operand2) { case EOperand2.RotateImmediate: bw.WriteBits(Rotate, 8, 4); bw.WriteBits(Immediate, 0, 8); break; case EOperand2.ImmediateShiftRm: bw.WriteBits(ShiftCount, 7, 5); bw.WriteBits((int)ShiftInst, 5, 2); bw.WriteBits(0, 4, 1); bw.WriteBits((int)Rm, 0, 4); break; case EOperand2.RsShiftRm: bw.WriteBits((int)Rs, 8, 4); bw.WriteBits(0, 7, 1); bw.WriteBits((int)ShiftInst, 5, 2); bw.WriteBits(1, 4, 1); bw.WriteBits((int)Rm, 0, 4); break; } return(bw.GetValue()); }
public byte[] Encode() { if (!Decoded) { throw new InvalidOperationException(); } var bw = new BitWriter(); bw.WriteBits((int)Condition, 28, 4); // Condition bw.WriteBits(1, 27, 1); bw.WriteBits(WriteBack ? 1 : 0, 21, 1); bw.WriteBits(Load ? 1 : 0, 20, 1); bw.WriteBits((int)Rn, 16, 4); bw.WriteBits(RegisterList, 0, 16); return(bw.GetValue()); }
public byte[] Encode() { if (!Decoded || !Linked) { throw new InvalidOperationException(); } var bw = new BitWriter(); bw.WriteBits((int)Condition, 28, 4); // Condition bw.WriteBits(1, 26, 1); bw.WriteBits(Offset == EOffset.ImmediateShiftRm ? 1 : 0, 25, 1); bw.WriteBits(PreIndex ? 1 : 0, 24, 1); bw.WriteBits(Up ? 1 : 0, 23, 1); bw.WriteBits(DataSize == EDataSize.Byte ? 1 : 0, 22, 1); bw.WriteBits(WriteBack ? 1 : 0, 21, 1); bw.WriteBits(Load ? 1 : 0, 20, 1); bw.WriteBits((int)Rn, 16, 4); bw.WriteBits((int)Rd, 12, 4); switch (Offset) { case EOffset.None: case EOffset.Immediate: bw.WriteBits(Immediate, 0, 12); break; case EOffset.ImmediateShiftRm: bw.WriteBits(ShiftCount, 7, 5); bw.WriteBits((int)ShiftInst, 5, 2); bw.WriteBits((int)Rm, 0, 4); break; default: throw new ArgumentOutOfRangeException(); } return(bw.GetValue()); }
public byte[] Encode() { if (!Linked) { throw new InvalidOperationException(); } var bw = new BitWriter(); bw.WriteBits((int)Condition, 28, 4); // Condition switch (JumpType) { case EJump.BranchLink: bw.WriteBits(1, 24, 1); goto case EJump.Branch; case EJump.Branch: bw.WriteBits(1, 27, 1); bw.WriteBits(1, 25, 1); bw.WriteBits(Offset, 0, 24); break; case EJump.BranchExchange: bw.WriteBits(1, 24, 1); bw.WriteBits(1, 21, 1); bw.WriteBits(1, 4, 1); bw.WriteBits((int)Rm, 0, 4); break; default: throw new ArgumentOutOfRangeException(); } return(bw.GetValue()); }