Opcode Encoding - philpax/skiron GitHub Wiki
Encoding A
Used for three-register instructions.
Field Layout
6 bits | 2 bits | 2 bits | 6 bits | 6 bits | 6 bits | 2 bits | 2 bits |
---|---|---|---|---|---|---|---|
opcode |
encoding |
variant |
register1 |
register2 |
register3 |
padding |
operandSize |
opcode
(ubyte
, 6 bits): The opcode number.encoding
(Encoding
, 2 bits): The encoding in use.variant
(Variant
, 2 bits): The variant/modifier to apply to register3.register1
(Register
, 6 bits): The destination register.register2
(Register
, 6 bits): The first source register.register3
(Register
, 6 bits): The second source register.padding
(ubyte
, 2 bits)operandSize
(OperandSize
, 2 bits): The sizes of the operands being used.
Encoding B
Used for one-register, one-immediate instructions.
Field Layout
6 bits | 2 bits | 2 bits | 6 bits | 16 bits |
---|---|---|---|---|
opcode |
encoding |
variant |
register1 |
immediate |
opcode
(ubyte
, 6 bits): The opcode number.encoding
(Encoding
, 2 bits): The encoding in use.variant
(Variant
, 2 bits): The variant/modifier to apply to the immediate.register1
(Register
, 6 bits): The destination/source register.immediate
(ushort
, 16 bits): The encoded unsigned immediate value.
Encoding C
Used for one-immediate instructions.
Field Layout
6 bits | 2 bits | 2 bits | 20 bits | 2 bits |
---|---|---|---|---|
opcode |
encoding |
variant |
immediate |
operandSize |
opcode
(ubyte
, 6 bits): The opcode number.encoding
(Encoding
, 2 bits): The encoding in use.variant
(Variant
, 2 bits): The variant/modifier to apply to the immediate.immediate
(int
, 20 bits): The encoded signed immediate value.operandSize
(OperandSize
, 2 bits): The sizes of the operands being used.
Encoding D
Used for two-register, one-immediate instructions.
Field Layout
6 bits | 2 bits | 2 bits | 6 bits | 6 bits | 8 bits | 2 bits |
---|---|---|---|---|---|---|
opcode |
encoding |
variant |
register1 |
register2 |
immediate |
operandSize |
opcode
(ubyte
, 6 bits): The opcode number.encoding
(Encoding
, 2 bits): The encoding in use.variant
(Variant
, 2 bits): The variant/modifier to apply to the immediate.register1
(Register
, 6 bits): The destination register.register2
(Register
, 6 bits): The source register.immediate
(int
, 8 bits): The encoded signed immediate value.operandSize
(OperandSize
, 2 bits): The sizes of the operands being used.
Variants
The last argument of an instruction can be modified by a Variant before being used in a computation.
- Identity
- Index: 0
- Description: Pass the operand through unchanged.
- ShiftLeft1
- Index: 1
- Description: Shift the operand 1 bit to the left.
- ShiftLeft2
- Index: 2
- Description: Shift the operand 2 bits to the left.
Operand Formats
An opcode has an operand format, which specifies which arguments it takes.
- Dst
- Description: Destination (register)
- Encoding: A
- Operand size support: true
- Uimm
- Description: Source (unsigned immediate)
- Encoding: B
- Operand size support: false
- DstSrc
- Description: Destination (register), source (register)
- Encoding: A
- Operand size support: true
- DstSrcSrc
- Description: Destination (register), source (register), source (register)
- Encoding: A
- Operand size support: true
- DstUimm
- Description: Destination (register), source (unsigned immediate)
- Encoding: B
- Operand size support: false
- DstSrcImm
- Description: Destination (register), source1 (register), source2 (immediate)
- Encoding: D
- Operand size support: true
- Label
- Description: Label (immediate)
- Encoding: C
- Operand size support: false
- None
- Description: No operands
- Encoding: A
- Operand size support: false