diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-02-16 22:55:12 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-02-16 22:55:12 -0800 |
commit | de2990880ab7ac98db79747a2eaedc3442fd4afc (patch) | |
tree | 16f1e3cf257c78ff05de6e999c2118e0f537e830 /003trace.test.cc | |
parent | bf1fe33c369d815676c4b7b3a334a6d971988f64 (diff) | |
download | mu-de2990880ab7ac98db79747a2eaedc3442fd4afc.tar.gz |
4976 - recommend that operand order be fixed
I've been allowing operands in any order just because it simplifies implementation. I don't actually rely on this flexibility; all the .subx programs in this repo consistently use a single ordering. Why is a hard-coded canonical order hard to implement? The order that seems most logical to me is complicated by the "reg" bits in the ModR/M byte: - In instructions that interpret it as an `/r32` operand, it needs to be deemphasized because it refers to a different argument of the instruction than the `/mod`, `/rm32`, `/base`, `/index` and `/scale` operands that capture the bulk of instruction decoding complexity and so should be emphasized. `/r32` can also be unused, which strengthens the case for deemphasizing it. - In instructions that interpret the "reg" bits as a `/subop` operand, it should be colocated with the opcode because it performs the same function: specifying the *operation* the instruction performs. In both cases, the bits in the `reg` bitfield are conceptually unrelated to the other bitfields in the same byte. But they sometimes want to be close to the opcode bytes on the left, and at other times need to be deemphasized rightward. Fixing both these possibilities seems complicated and stateful, particularly since all operands are optional in general. On the other hand, just pulling operands you need to create each byte, regardless of where in the instruction they occur, that's nicely stateless.
Diffstat (limited to '003trace.test.cc')
0 files changed, 0 insertions, 0 deletions