How to calculate an instruction encoding? like calculate the encoding for fctidu 2, 3 (Here we are using Power PC hardware instruction as an example)
(a)First find the Instruction description in the ISA document. In this example, On page 141 of Power ISA V2.06
(b) Second, replace the operand field according to the encoding format. e.g., fctidu 2, 3 belong to
the first format (Record Form, It “records” the result (i.e. saturation in this case I guess) in CR1), so Rc is 0,
FRT is the first operand, its value is 2, and FRB is the second value, its value is 3, therefore, the encoding value
will be:
bit: 0-5 6-10 11-15 16-20 21-30 31
original: | 63 | FRT | /// | FRB | 942 | Rc |
Decimal replace: |63 | 2 | 0 | 3 | 942 | 0 | // note: here "///" in the ISA meaning all 0 (probably because it's padding)
in binary:
| 11 1111 | 00010 | 00000 | 00011 | 11 1010 1110 | 0 |
re-organized by 8 bits (by byte)
| 1111 1100 | 0100 0000 | 0001 1111 | 0101 1100 |
in Hexadecimal:
| FC | 40 | 1F | 5C |
(c) Therefore, the eventually encoding is 0XFC 0X40 0X1F 0X5C
file reference:
test/MC/PowerPC/ppc64-encoding-fp.s -- tests assembly
test/MC/Disassembler/PowerPC/ppc64-encoding-fp.txt -- tests disassembly
No comments:
Post a Comment