about summary refs log tree commit diff stats
path: root/017parse_tree.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-16 22:55:12 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-16 22:55:12 -0800
commitde2990880ab7ac98db79747a2eaedc3442fd4afc (patch)
tree16f1e3cf257c78ff05de6e999c2118e0f537e830 /017parse_tree.cc
parentbf1fe33c369d815676c4b7b3a334a6d971988f64 (diff)
downloadmu-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 '017parse_tree.cc')
0 files changed, 0 insertions, 0 deletions
/a> 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231