about summary refs log tree commit diff stats
path: root/078emit-hex.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-03-21 15:32:30 -0700
committerKartik Agaram <vc@akkartik.com>2020-03-21 16:51:52 -0700
commitdf609237c1f583544b814454efb4790a67f7fd68 (patch)
treea5302018c77b775477501f71412b475763a87979 /078emit-hex.subx
parentc6886c1c97dd636750778b1cfec437056906cd38 (diff)
downloadmu-df609237c1f583544b814454efb4790a67f7fd68.tar.gz
6158 - standardize opcode names
At the lowest level, SubX without syntax sugar uses names without prepositions.
For example, 01 and 03 are both called 'add', irrespective of source and
destination operand. Horizontal space is at a premium, and we rely on the
comments at the end of each line to fully describe what is happening.

Above that, however, we standardize on a slightly different naming convention
across:
  a) SubX with syntax sugar,
  b) Mu, and
  c) the SubX code that the Mu compiler emits.

Conventions, in brief:
  - by default, the source is on the left and destination on the right.
    e.g. add %eax, 1/r32/ecx ("add eax to ecx")
  - prepositions reverse the direction.
    e.g. add-to %eax, 1/r32/ecx ("add ecx to eax")
         subtract-from %eax, 1/r32/ecx ("subtract ecx from eax")
  - by default, comparisons are left to right while 'compare<-' reverses.

Before, I was sometimes swapping args to make the operation more obvious,
but that would complicate the code-generation of the Mu compiler, and it's
nice to be able to read the output of the compiler just like hand-written
code.

One place where SubX differs from Mu: copy opcodes are called '<-' and
'->'. Hopefully that fits with the spirit of Mu rather than the letter
of the 'copy' and 'copy-to' instructions.
Diffstat (limited to '078emit-hex.subx')
0 files changed, 0 insertions, 0 deletions