The New Jersey Machine-Code Toolkit FAQ

Q. I want to know exactly how long each instruction is, but that's a lot of bookkeeping. Can the toolkit do it?

A. Yes. On page 25 of the verion 0.5 manual, it describes the construct
match [succ] pc-expression to
| ...
This will cause the toolkit to assign to succ the address of the first byte not matched. You can then subtract the starting PC to find the size of the instruction.

Q. I don't want to be limited to encoding one procedure at a time. What do I do?

A. The toolkit's relocatable blocks aren't restricted to procedures, segments, or any other unit of granularity. A relocatable block can represent anything you want it to represent (e.g., basic blocks).

Q. When the toolkit decodes instructions, it doesn't properly sign-extend my displacements. What's wrong?

A. If your displacements are relocatable addresses, things get tricky. (The whole business of non-field operands requires more thought than I have really given it.) If, for example, you write
  fields of op (8)  reg 0:2
  fields of imm8 (8) i8 0:7
  relocatable d
  constructors Disp d![reg] is reg; i8 = d
there are two reasonable interpretations: d holds a signed value that should fit in 8 bits, or d holds an unsigned value that should fit in 8 bits. As it turns out, the latter interpretation is the default. To get a signed interpretation, write
  constructors Disp d![reg] is { i8! = d } reg; i8
Your decoders should then sign-extend properly.