Skip to content

Commit 6e50196

Browse files
committed
gemu: disasm highlight tracks instruction-start PC (no drift onto operands)
The wasm assembly window centred on the live rPO, which advances mid-instruction (operand fetch, and jump-target recomputation), so the "current line" highlight drifted onto operand DB bytes and the next instruction — most visibly across a jump. Latch ge->instr_pc in the alpha fetch (state e2/e3), where PO addresses the opcode and is not advanced within the state. It stays on the executing instruction while operands are read and PO is recomputed, and only moves when the next instruction is actually fetched (jumping straight to the target's opcode, never onto a DB byte). The wasm disassembly window now centres on instr_pc. Verified over a deck run: instr_pc lands only on real opcodes (07/43/95/92/d2…) and follows jumps to their targets. Suite 251/251.
1 parent 10ba531 commit 6e50196

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

console/wasm/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,13 @@ void send_console() {
157157
set_lamp("LOAD_2", console.lamps.LOAD_2 );
158158
set_lamp("OPERATOR_CALL", console.lamps.OPERATOR_CALL );
159159

160-
/* gdb-style disassembly window centred on the program counter (PO). */
160+
/* gdb-style disassembly window centred on the instruction-start PC
161+
* (latched in the alpha fetch), so the highlight stays on the instruction
162+
* being executed instead of drifting onto operand bytes / the next line as
163+
* the live PO advances mid-instruction (e.g. while computing a jump). */
161164
{
162165
static char dis[1536];
163-
ge_disasm_window(ge->mem, ge->rPO, 5, 6, dis, sizeof dis);
166+
ge_disasm_window(ge->mem, ge->instr_pc, 5, 6, dis, sizeof dis);
164167
set_disasm(dis);
165168
}
166169
}

ge.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ int ge_run_pulse(struct ge *ge)
305305
return 1;
306306
}
307307

308+
/* Latch the instruction-start PC for the disassembly display. In the alpha
309+
* fetch (e2/e3) PO addresses the opcode and is NOT advanced within the state
310+
* (operand fetch / PO recomputation happens in the later e0/e4/e6 states), so
311+
* this is the address of the instruction now executing. It stays put while
312+
* operands are read and PO is recomputed (e.g. across a jump), so a UI
313+
* highlight tracking it does not drift onto operand (DB) bytes or the next
314+
* line — it only moves when the next instruction is actually fetched. */
315+
if (ge->rSA == 0xe2 || ge->rSA == 0xe3)
316+
ge->instr_pc = ge->rPO;
317+
308318
msl_run_state(ge, state);
309319

310320
if (ge_clock_is_last(ge)) {

ge.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ struct ge {
112112
*/
113113
uint16_t rPO;
114114

115+
/**
116+
* Instruction-start PC (display aid, not a real register). Latched in the
117+
* alpha fetch (state e2/e3) to the address of the opcode being executed, so
118+
* UI disassembly can highlight the current instruction without drifting onto
119+
* operands or the next line as rPO advances mid-instruction.
120+
*/
121+
uint16_t instr_pc;
122+
115123
uint16_t rV1; ///< Addresser for the first operand
116124
uint16_t rV2; ///< Addresser for the second operand
117125
uint16_t rV3; ///< Addresser for external instructions using channel 3

0 commit comments

Comments
 (0)