TFR/EXG to/from internal TMP2/TMP3 silently ignored #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The
TFR/EXG/SEXdecoder (ExecuteTransfer,M68HC12.cs:1112-1142)silently drops any transfer that involves the internal
TMP2/TMP3registers:
In the
B7post-byte, source/dest register codes0-2,4-7map toA, B, CCR, D, X, Y, SP; code
3selects the internal temp register(
TMP2for a 16-bit transfer,TMP3when the operation implies it).Impact
TFR/EXG/SEXnamingTMP2/TMP3completes without doinganything — registers are not modified and no warning is logged, so the
program silently computes wrong results.
EMULM/EDIVM(and related)forms that use the TMP registers; those are unusable while TMP is not
modeled.
Current behavior
The post-byte is fetched,
sourceCode/destCodeextracted, and a barereturnoccurs for code 3 — the rest of the transfer (including the SEXsign-extension path) is skipped.
Affected files
src/Infrastructure/src/Emulator/Peripherals/Peripherals/CPU/M68HC12/M68HC12.cs:1112-1142Desired behavior
TMP2/TMP3as internal 16-bit registers (visible to the monitor fordebugging, but not part of the GDB register set unless GDB expects them).
TFR/EXG/SEXpost-byte table so code3transfersto/from the temp register work, including the SEX 8-bit→16-bit
sign-extension rule.
Acceptance criteria
TFRA,TMP2 / EXG D,TMP3 and similar post-byte combos update the tempregisters and the paired register exactly once (correct swap for EXG).
TFR/EXGrow and the binutilsM6812_OP_TFR_MARKER/M6812_OP_EXG_MARKERdecode(
docs/m68hc12/reference/binutils-m68hc11-opc.c,docs/m68hc12/reference/binutils-opcode-m68hc11.h).code
3.by the unimplemented-opcode trap with a warning.
Suggested approach
ushortfields (or reuse the register array) for TMP2/TMP3.TransferRegister(M68HC12.cs:1144) to map code3to the tempregister instead of falling into the
default(SP) case.sign-extends; the same rule already exists for A/B/CCR sources and should
apply uniformly to the temp register.