140. Bit 15 of a comparison is the else arm, and the queue is writable because of it¶
Section 34 read 0x70 and 0x71 down to the XORLW chain that picks one of eight operations out of
the operand's high byte, and recorded what it could not read.
bit 15 is a separate flag on the high byte, which the dispatcher masks off with
& 0x0F
That was true of the nibble decode and false of the instruction. The same handler tests the bit eighty instructions later, and what it does is the language's else arm.
How it was found is worth stating, because it was not by looking for it. The population of eight
test classes was widened from ten configs to all fifteen user configs, entry 26 of section 139, and a
scratch measurement of the operand's whole high byte printed values 0x80 to 0x84 beside the
expected 0x00 to 0x05. Every test still passed, because every one of them masks with 0x0F first,
copying the firmware. So a field that no reader read and no test could see had been in every config in
the corpus from the beginning, and what surfaced it was printing a byte instead of a nibble.
The firmware¶
On the Harmony 700 image, the selector chain starts at 0x0EEA8:
0eea8: MOVLW 0x0f
0eeac: ANDWF 0x1bc,W the operand's high byte, masked to the selector
0eeae: XORLW 0x07 the chain section 34 read
...
0ef62: BTFSS 0x1bc,7 the same byte, bit 7
0ef64: BRA 0x0efe0 clear: the one armed form
0ef66: MOVF 0xd08,W the comparison's result
0ef6a: BZ 0x0efe8 false: skip the next instruction
0ef6c: MOVFF 0x19f,0xd09 true: the interpreter's own queue pointer
0ef70: MOVFF 0x1a0,0xd0a
0ef74: MOVLW 0x03 one instruction width
0ef76: ADDWF 0x09,B,F
0ef7c: MOVLW 0x9f the wrap bound, 0x019F
...
0ef8e: MOVFF 0xd09,FSR0L and three bytes zeroed, one at a time, wrapping
0ef96: CLRF INDF0
0x19F and 0x1A0 are the queue's read pointer: 0x0E82C loads them into FSR0, fetches a byte and
increments, which is how the executor consumes an instruction. By the time a handler runs, that
pointer already sits on the next instruction, so +3 lands on the one after it, and the three
CLRF INDF0 overwrite that instruction with 0x00 0x00 0x00. Opcode 0x00 does nothing.
The two paths out are the reading:
| bit 15 | comparison | what happens |
|---|---|---|
| clear | false | the next instruction is skipped, by fetching its three bytes and discarding them at 0x0EFE8 |
| clear | true | nothing further: the next instruction runs |
| set | false | the same skip, so the instruction after the next one runs |
| set | true | the instruction after the next one is zeroed, and the next one runs |
So the two instructions following a flagged comparison are its two arms, and whichever is not taken is neutralised rather than jumped over. That is not a stylistic choice. The handler returns before either arm runs, and the interpreter has no way to skip an instruction it has not reached yet, so cancelling the untaken arm has to happen in advance, by writing over it. Which answers a question this project had not asked: why the action list interpreter runs out of a 120 byte circular buffer in RAM rather than straight out of the memory mapped config on arch 12 (Harmony One). It is not only a queue. It is the instruction stream, and the language mutates it.
It is one table across architectures¶
Two structures in this language are not, 0x3F's bands and the block 0x65 to 0x6E, and section
139 found a third the day before this one, where 0x0F's bands had been read on arch 12 (Harmony One)
and arch 14 (Harmony 600 and 700) and applied to arch 9 (Harmony 525), which does not implement them.
So an "every architecture" claim about this interpreter is exactly the kind that has been wrong here,
and this one is measured per image rather than ported. The route on each is the same: find the
MOVLW 0x0F; MOVLB b; ANDWF f,W that opens the chain, then trace f.
| image | architecture | mask | BTFSS f,7 |
the byte |
|---|---|---|---|---|
h700_code |
14 (Harmony 700) | 0x0EEAC |
0x0EF62 |
0x1BC |
h600_code_complete |
14 (Harmony 600) | 0x0EABC |
0x0EB72 |
0x2B3 |
h650_code |
14 (Harmony 650) | 0x0EE9A |
0x0EF50 |
0x1BC |
one34_code |
12 (Harmony One) | 0x2519C |
0x25252 |
0xEBE |
h525_code |
9 (Harmony 525) | 0x01E48 |
0x01EFE |
0x3D8 |
arch8_code_880 |
8 (Harmony 880) | 0x133EA |
0x134A0 |
0x3B3 |
arch8_code_885 |
8 (Harmony 885) | 0x133EA |
0x134A0 |
0x3B3 |
Seven images, four architectures, and exactly one test of that bit in each: if there were two, the
reading would be incomplete. Arch 9 (Harmony 525) is compiled with less inlining and is the case to
check rather than skip: one CLRF INDF0 sits inline and a helper at 0x024F8 clears, increments and
bounds, called twice, so it is three clears the same as everywhere else.
The tracer earns its keep here and a sweep does not. The first version of the test decoded each
image linearly from offset 0 and reported a second bit 7 test on both arch 8 images, at 0x1259C. It
is not one: a linear decode has no idea which bank is selected, so it read byte 0xB3 of some other
bank as this one. harmony/pic18/trace.py follows MOVLB and reports one site. An extra hit that
looks like a finding is what the bank tracking exists to prevent, and it was believed for about a
minute.
The corpus closure, and it is exact in both directions¶
Nothing in the container states how many instructions belong to a conditional, so the arm count is a pure prediction of the firmware reading. Over all fifteen user configs, four architectures:
| bit 15 | instructions | followed by |
|---|---|---|
| clear | 2084 | exactly one instruction, and the list ends there |
| set | 600 | exactly two instructions, and the list ends there |
Never three, never none, no exception. A wrong reading of the flag would show up here as a conditional whose arms run off the end of its own list, or as a list with bytes at the end that nothing reaches. And the shape is stronger than the counts: no list holds two conditionals and no arm is itself a conditional, so an action list is a straight run with at most one branch at the end of it, and an editor never has to reason about a nested condition.
What the arms hold says how a config gets more than one instruction into a branch: 2357 of the 3284
arms are 0x7F, a call to another action list. The 17 arms that are opcode 0x00 are an explicitly
empty branch, which is the corpus agreeing with the mechanism from the other side, since zeroing
a slot is exactly how the flag cancels an arm.
The bit is set on 600 instructions and all of them are 0x71. That is a fact about the corpus and not
about the format: one handler serves both opcodes and tests the bit for both, so a two armed 0x70 is
representable and no generator has emitted one. packages/codec/src/actions.ts reads it for both,
because a reading is about the instruction.
Bits 12 to 14 are read by nothing and set in no instruction in the corpus, so the high byte is a nibble and a flag with three dead bits between them.
Two numbers corrected in place¶
Section 34 said 0x71 uses selectors 0 to 5 "over 2164 uses"; the figure over all fifteen user
configs is 2477. And section 33 said the 0x7C count beside an infrared send takes six values,
0, 1, 2, 4, 5, 10; it takes seven, adding 3, from arch8_config_885. Both were properties of the
ten configs those sections were written against. The 0x7C one is the instructive half, because the
set was doing the work of the claim: what rules out that operand being a second identifier is that an
identifier would have to separate the records of a group and the largest group here holds 111, while
the firmware caps this field at 100. The bound is the argument and the set is an observation, and the
test now says so in that order.
What would falsify it¶
A config whose flagged comparison is the last instruction in its list, or has three instructions after
it, either of which would say the arm count is not what the flag means. A config setting bit 15 on
0x70, which is representable and would move that line from a corpus fact to a format one, or bits 12
to 14 on anything, which would say the high byte has a third field. An arch 10 (Harmony 890) or arch 7
image whose handler does not test the bit, which would take this off the list of structures that are
one table across architectures. And, for the mechanism rather than the field: an action list
interpreter found reading instructions from anywhere other than a writable copy, which would leave the
zeroing with nothing to write to.
Section 139 | the archive | section 141. Section 140 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.