Reading Fields of a Toy Instruction
An instruction format assigns bit fields to its operation and operands. Their meanings depend on that instruction set.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Decode one layout
Suppose an eight-bit toy instruction uses a three-bit opcode and two register numbers in the remaining fields, one of width two and one of width three. The pattern 10110111 splits as 101, 10, 111. Bit field extraction reads those numeric codes.
Check a range limit
A two-bit register field can name four choices, even though the other field can name eight. A documented layout explains which roles have each set. The unsigned range gives the bounds.[1]
Decode one declared layout without guessing
Suppose an eight-bit toy word has two opcode bits, two register bits and four unsigned immediate bits from the high end down. The word 10 01 0110 selects opcode two, register one and immediate six. These meanings come from the toy specification. See extracting bit fields.
Word: 10010110
Bits 7–6: 10 → opcode 2
Bits 5–4: 01 → register 1
Bits 3–0: 0110 → immediate 6
Check interpretation after extracting bits
The same immediate pattern can mean a signed or unsigned value depending on opcode. Test a high immediate bit and a reserved opcode. If the instruction spans several bytes, decode file or instruction order before applying the field positions.