Skip to content

64. Screen opcode 22 is a call on arch 12 and a picture draw on arch 9

The third time an architecture's mode programs turned out to be shut by a single missing operand count, and the second time it was this pair of opcodes. Section 54 opened arch 12 with 23: 0. This opens arch 9, and it also answers what sections 62 and 63 had to leave standing.

Arch 12, from the firmware

Opcode 22 was in the arch 12 dispatcher and in no config, so its width was unestablished and both codecs refused it. Its handler is at 0x2966E on the Harmony One 3.4 image:

2966e: CALL 0x2b88a          ; the current stream position -> 0x01F..0x021
29672: MOVFF 0x01f,0xd34
29676: MOVFF 0x020,0xd35
2967a: MOVFF 0x021,0xd36     ; save it
2967e: MOVLW 0x03
29682: ADDWF 0xd34,F         ; ... plus three
29690: CALL 0x2b8ac          ; read a u24 and seek there

0x2B88A computes where the reader is and reads nothing. 0x2B8AC reads three bytes and makes them the new position. So opcode 22 consumes three operand bytes, jumps to the address they hold, and leaves the byte after them in 0xD34 to 0xD36. That is a call with a return address.

And it names the other half. Section 54 described 0x29640, opcode 23's handler, as copying the stream position into 0x19C to 0x19E and had no name for it. It copies 0xD34 to 0xD36, which is what opcode 22 wrote. Opcode 23 is the return.

A trace of those three bytes over the whole image, restricted to the dispatcher, shows exactly one writer and one reader: 0x29672 onwards and 0x29640 onwards. Outside the dispatcher the same RAM is reused by unrelated code, which is why the restriction is in the test rather than assumed away.

One link register, not a stack, so these calls do not nest. That is a writer rail.

No config in the corpus uses opcode 22 on arch 12, so the width is firmware and the semantics are untested against data.

Arch 9, from the corpus, because there is no firmware

Corrected by section 85: the width is one, not eleven. The rest of this part stands, including every byte quoted below and the picture it lands on, because both readings consume the same twelve bytes; what section 85 changes is that the 03 in the second column is an opcode rather than an operand, and the address belongs to it. Read on for how the wrong structure survived a closure and a calibration, which is the instructive part.

Every arch 9 mode record's tail starts 16 00 03 00 00 00 00 60 08 8b 2f 03 17, repeated with an incrementing first operand byte. Eight of them, and the middle bytes step by eight:

00  03 00  00 00  00  60 08  8b 2f 03
01  03 00  08 00  08  60 08  8b 2f 03
02  03 00  10 00  10  60 08  8b 2f 03
...
07  03 00  38 00  38  60 08  8b 2f 03

The 525's screen is 96 by 64 and 0x60 is 96, so eight bands of eight rows cover it exactly. The individual fields are not claimed here. What is claimed is the width, eleven, and that the last three bytes are a u24.

The closure is that the u24 is always a picture. Walking the bank from where base slot 17 says it starts, section 62, gives four addresses. At width eleven, all 912 instances across all 114 mode records name one of those four. At every other width from 3 to 15, zero do.

That closure is real and it is not evidence for eleven, which section 85 is about: the u24 is opcode 3's operand either way, and no width other than eleven puts opcode 22's own operands on top of it. A closure that only one candidate can satisfy does not distinguish that candidate from the one that reads the same bytes differently.

The calibration matters because the obvious criterion is useless here. Six widths, 0 through 5, also decode all 114 records, because a short operand count simply lands the walk on a byte that happens to be a valid opcode. That is exactly the ambiguity section 54 could not resolve for opcode 23 and had to take to the firmware. Here there is no firmware and the corpus separates the candidates by itself, on a criterion the candidates cannot influence.

So SCREEN_FIXED_OPERANDS can no longer hold opcode 22 at all: it is the one opcode whose width differs by architecture, three on arch 12 and eleven on arch 9. And only arch 12's address is a program; arch 9's is a picture and must not be walked into.

What it opens

before after
arch 9 mode records carrying a screen program 0 of 114 114 of 114
reachable screen programs in the 525 config 22 136
inline string codes in the 525 config 0 1205, all resolving
byte accounting, 525 25.7% 49.8%

MODE_PROGRAM_ARCHITECTURES is now all four.

The 1205 strings are the real prize, because they close section 63 rather than this one. Section 46's third check, that every inline code lands on a non NULL glyph of the font its own program selected, was unavailable on arch 9 this morning for want of any strings to check. The codes now resolve, and tools/screen_dump.py --strings draws them as readable English phrases. The glyph packing was derived from row and height arithmetic and the operand width from picture addresses, so neither finding fed the other and their agreement is a genuine check.

Where it lands

  • gspm.SCREEN_OPERANDS_BY_ARCHITECTURE, SCREEN_CALL, SCREEN_CALL_TARGET_ARCHITECTURES, replacing SCREEN_ARCH12_ONLY; the same three in packages/codec/src/screen.ts. MODE_PROGRAM_ARCHITECTURES gains 9 in both.
  • Sections 62 and 63 corrected in place: both said nothing in the 525's config draws the thing they had just read, and both were wrong for the same reason.
  • tests/test_interpreter.py, TestScreenOpcode22: the dispatcher case, the link register trace, the 912 pictures, the calibration over every other width, and the 1205 strings.

Section 63 | the archive | section 65. Section 64 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.