Skip to content

255. An arch 9 instruction is operand then opcode, and the chain switches on the operand

Read sections 256 and 257 first. This section's headline, that opcodes 0x1F to 0x3E dispatch on the operand's high byte, is section 72's, measured on arch 12 a month earlier and stated in a table row there, and arch 9's own ladder was already in section 139's entry 23. What this adds is the staging and working registers and the fetch; the reading was not open and should not have been presented as settled here.

Section 254 left one thing open, which byte the Harmony 525's interpreter dispatches on, and it named the two readings that disagreed. Following the fetch routine resolves the disagreement on this image and refutes one of that section's claims: 0x3D8 is the byte, and 0x3D8 holds the operand's high byte, so the 0xC0 to 0xCF band is a band of an operand rather than of an opcode. Section 72 had that on arch 12 already, per the header above.

The fetch, and the third confirmation of the ring

0x0193A returns one byte and is the only way the interpreter reads one:

0193a: FSR0 = 0x3BE, 0x3BF        the read pointer
01942: 0x700 = INDF0              the byte
01948: DECF 0x345,F               one fewer byte pending
0194a: pointer += 1
01950: compare pointer with 0x03BE
0195a: pointer = 0x0346           wrap to the base
01964: return the byte in W

That is section 254's ring a third time, from a routine that names both constants in one place: base 0x0346, end 0x03BE, and a pointer that advances by one byte rather than by an instruction. It also gives one address that section was missing: the count of bytes pending sits at 0x345, immediately below the ring's base, and the fetch decrements it.

An instruction is three bytes, operand first

The interpreter's loop head, 0x01BA2, fetches three bytes into a staging triple and then copies them into the working registers:

01ba2: fetch -> 0x754
01ba8: fetch -> 0x755
01bae: fetch -> 0x756
01bb4: MOVLW 0x1f; SUBWF 0x756,W; BNZ    is the third byte 0x1F?
01bba: MOVLW 0xfc; SUBWF 0x755,W; BNZ    with the second byte 0xFC?
01bc0: MOVFF 0x754,0x3cf; GOTO 0x01b10   a special case
01bc8: 0x3D7 = 0x754, 0x3D8 = 0x755, 0x3D9 = 0x756

The comparison against 0x1F is what identifies the field order. 0x1F is an action list opcode this project already reads on arch 12 and arch 14, and docs/config-format.md records it carrying a sub-command in the operand's high byte, 0xFE to push into a table and 0xFF to carry an index. The loop head tests the third byte against it and the second byte against a high byte value, 0xFC. So the third byte is the opcode and the second is the operand's high byte, which is exactly the format's own { u16 operand; u8 opcode } little endian, read in file order:

ring byte staged at working register field
first 0x754 0x3D7 operand, low byte
second 0x755 0x3D8 operand, high byte
third 0x756 0x3D9 opcode

0xFC is a third value of that sub-command byte and it is new here. What it does is unread: it copies the operand's low byte to 0x3CF and jumps out of the loop.

So the band is an operand's, and the bank is proven rather than inferred

The outer dispatch is on the opcode. 0x01C8E compares 0x3D9 against 0x6F with MOVLB 0x3 two instructions earlier, so that read is resolved, and opcodes below 0x6F branch to 0x01F6A. From there to the re-validation there is no MOVLB on the path: 0x01F6A and 0x01F72 narrow the opcode to [0x1F, 0x3F), then 0x01F7A, 0x01F90, 0x01FD6 and 0x02032 test the same second byte against 0xF0, 0xE0, 0xD0 and 0xC0, and 0x02038 masks its low nibble. The first MOVLB after the branch is at 0x0203C, after every one of those tests.

That is a chain of custody rather than a bank inference, which matters because losing the bank is what left section 254 open and what section 253 recorded as a pitfall. The way to settle it was to find the last explicit MOVLB before the branch and check that nothing between there and the site changes it, and that is worth doing whenever the disassembler prints the banked form.

So the instruction that asks a Harmony 525 to re-validate is an opcode in 0x1F to 0x3E with the operand's high byte in 0xC0 to 0xCF, and that high byte's low nibble chooses which container goes first. The bands above it, 0xD0, 0xE0 and 0xF0, are three more sub-command groups of the same operand byte, and what they do is unread.

Where it lands

  • tests/test_status_screens.py: the field order with the 0x1F comparison that proves it, the fetch's wrap naming both ring constants, the pending count below the base, and the opcode band with the operand band kept separate.
  • docs/config-format.md: the field order per architecture, and the re-validation restated as an operand band.
  • Section 254, corrected in place, and reference/superseded.md.

Section 254 | the archive | section 256. Section 255 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.