Closed fredrikr closed 5 years ago
Also, section 14 doesn't mention that je can take more than two arguments.
I've tried to rewrite bits of section 4 to be clearer. Relevant parts below, with changes in bold.
4.3 Each instruction has a form (long, short, extended or variable), an operand count (0OP, 1OP, 2OP or VAR) and an opcode number. If the top two bits of the opcode are $$11 the form is variable; if $$10, the form is short. If the opcode is 190 ($BE in hexadecimal) and the version is 5 or later, the form is "extended". Otherwise, the form is "long". Which opcode an opcode number refers to depends on the operand count.
4.3 Each instruction has a form (long, short, extended or variable) and an operand count (0OP, 1OP, 2OP or VAR). If the top two bits of the opcode are $$11 the form is variable; if $$10, the form is short. If the opcode is 190 ($BE in hexadecimal) and the version is 5 or later, the form is "extended". Otherwise, the form is "long".
4.3.3 In variable form, if bit 5 is 0 then the count is 2OP; if it is 1, then the count is VAR. The opcode number is given in the bottom 5 bits.
4.5 The operands are given next. If the operand count is VAR, or the operand count is 2OP and the form is variable, there must be as many operands as there were types other than 'omitted'. Otherwise, operand counts of 0OP, 1OP or 2OP require 0, 1 or 2 operands to be given, respectively.
Does this make sense? More importantly, is it actually accurate?
Actually, I don't like this, because the 'operand count' now doesn't relate to the operand count. I may have to do more extensive rewriting.
How about this:
4.3 Each instruction has a form (long, short, extended or variable), an operand count (0OP, 1OP, 2OP or VAR) and an opcode number. If the top two bits of the opcode are $$11 the form is variable; if $$10, the form is short. If the opcode is 190 ($BE in hexadecimal) and the version is 5 or later, the form is "extended". Otherwise, the form is "long".
Which opcode an opcode number refers to generally depends on the operand count, so that there are 0OP, 1OP, 2OP and VAR opcodes (see section 14). Opcodes using the "extended" form are referred to as EXT opcodes. In addition, 2OP opcodes may also be encoded in variable form.
4.3.3 In variable form the count is VAR. If bit 5 is 0 then the opcode is 2OP; if it is 1, then the opcode is VAR. The opcode number is given in the bottom 5 bits.
4.5 The operands are given next. If the operand count is VAR (whether the opcode is a VAR or a 2OP) there must be as many operands as there were types other than 'omitted'. Otherwise, operand counts of 0OP, 1OP or 2OP require 0, 1 or 2 operands to be given, respectively.
The standard could be clearer on the fact that a 2OP instruction may not always have two arguments, like @je. Not sure if @je is the only exception, and if there are any exceptions for 0OP and 1OP instructions.
This would at the very least affect the text in 4.3 and 4.5.