Brings in f1ccd92 (board reads move to dumps/), d138dc2 (3453 flash
boot, browser GUI, Apple USB Modem line, RTP/G.711, V.90 and x2 timing,
Quad) and e84e324 (native worker gate and resampler loops).
Conflicts:
- Frame timing (machine.py, worker_poll.py, native/c5x_capi.cpp): keep
the upstream frame-source code (_frame_irq_due, worker_frame_due, XF
edges). Add the fork's opt-in COURIER_INT0_TOUT source into those
functions, and keep COURIER_INT0_EXACT. The new struct fields are at
the end of WorkerPollState, in C and ctypes.
- bearer_line.py and the closed-loop probe: keep the fork's opt-in line
loss, noise and A-law test settings, with the upstream imports, frame
constants and dumps/ paths.
- Docs: keep the STE text of the fork, with the dumps/ paths. Keep the new
upstream sections. The README stays a short landing page. The new
README text of the upstream goes to docs/research-log.md,
docs/current-boundary.md, docs/usage.md and the new docs/gui.md (STE).
docs/README.md lists the new upstream notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRyJwNajT59BytMgdQ
Add captured 3453 flash boot and modem data-path support, a local browser
console, and an Apple USB Modem line backend. Improve I-modem and Quad
firmware timing, UART framing, and SIP/RTP media handling.
Include regression tests, compact hardware evidence, and documentation
for the measured link behavior. Keep pytest discovery scoped to tests/.
The board's INT0 is most likely the C52's TOUT, which the ASIC routes to
the CPU: in an x2 call the emulated C52's timer runs at 2,397 Hz on the
20.16 MHz time base, against 2,401 Hz counted on the live board. With
COURIER_INT0_TOUT=1 each TOUT pulse latches one request, as the 80186's
edge-triggered request bit does, whether or not IF is set, and the
first service step that IF and the in-service bit allow takes it. This
happens in the Python paths and in the native worker, which gains three
fields. COURIER_TOUT_LOG samples the timer for diagnosis.
At 0 dB and a service step of 256, a 54666 bit/s call carried 93 lines
against 30 before. With a full-rate INT0 the Courier's own upstream
signal degrades and 6 dB calls no longer train: see the write-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTieSnZY49zbAZzpUP
INT0 (the coprocessor frame edge) was only taken at a timer poll, every
1024 instructions, so edges came late or merged. At x2's 54666 bit/s the
DSP then drops whole bytes before its receive banks. With
COURIER_INT0_EXACT=1 and COURIER_NATIVE_SERVICE=256, the Python fast
path and the native worker take the edge at the first service step it
is due. Off by default. docs/x2-byte-loss.md has the evidence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTieSnZY49zbAZzpUP
In a live call every 125 us PCM frame came back to Python - advance_imodem,
_sync_pcm, the bearer exchange - and on tower that left the 386 ~2.4M
instructions/s, under the board's 5M, so the data lanes overflowed in a
burst of received frames. The native ImodemHostIo now runs the C5x in
wallclock mode up to a cycle target the harness sets from wall time
(set_wall_target, ImodemDsp.realtime_target), settling frames natively
as it does offline. BearerSipLine hands 10 ms of already-received data
ahead (feeds_ahead, receive_lead) so frames need not wait on Python; the
frame-by-frame pace_realtime path remains for far ends that cannot.
Tower, live X.75 to 7910: 4.64M instructions/s, menu acknowledged, no
REJ, FRMR or silence fill.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IRQ13 is the 386EX's INT6 pin (INTCFG 0x0d puts INT6 on slave IR5,
Intel386 EX manual figs 5-4/5-5), and its handler at b3d9:0000 is a
~2400 Hz tick: the firmware converts ms to ticks as ms*256/107. The C5x
runs PRD 0x41a4, 2399 Hz at 40.32 MHz, and on the 403 board its TOUT
goes into the ASIC that drives the CPU's interrupt lines. So instead of a
fixed instruction cadence, each timer expiry - C5xCore::timer_expiries,
counted in advance_timer whether TINT is masked or not - raises IRQ13,
in the Python poll and the native one. Without a DSP the old cadence
stays as the capture-only endpoint's stand-in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two things kept an I-modem X.75 call from linking up with the Eicon at
7910:
- SIP carried the B channel as voice. --bri-sip-codec offers pcma or
clearmode (RFC 4040, dynamic payload type, the peer's rtpmap number
adopted) as well as pcmu; codeword passthrough no longer insists on
PCMU. With clearmode the far gateway places a digital call.
- In a live call the 386 livelocked in its IRQ13 handler. The DSP posts
a data-lane word per bearer octet each way; with native host I/O off
for realtime peers every port access went through Python, the host ran
~150k instructions/s, never left the lane loop, never acknowledged
reply 0003 - so 0004, command 000a:0003 and the SABM only followed the
hang-up. Native I/O now stays live during a call in a wall-clock mode
that serves the ports without stepping the C5x, which pace_realtime
keeps driving.
Live result: CONNECT 64000/ARQ and the far end's menu.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stream sender (`out *, 0060` at 0x849e on the 403, 0x8980 on the
I-modem) writes a holding register nothing modelled, and flags the word in
a status bit nobody reported, so every streamed reply - ATI11's tag 57,
the idle page's 46, ATY12's 45 - timed out and read zero.
- c5x_core: port 0x60 in ROM-codec mode fills the output latch the CPU's
0x60/0x62 reads come from.
- 403 (bridge.py, LaneHostIo): status bit 2 is the stream word, cleared
the way bit 1 is for messages.
- I-modem (ImodemDsp, ImodemHostIo, isdn.py): 0x18 bit 7 is the stream
word (PA6 bit 7), 0x80 written to 0x18 acknowledges it, and 0x60/0x62
are routed to the DSP endpoint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
COURIER_DSP_TRACE_REGISTER=0x25 records every write to that register (cycle,
writing PC, value) and COURIER_DSP_TRACE_FILE writes them out, one JSON line
per core, as each core is retired. Used to rule out the timer as timing
recovery: on the 403 pair PRD only ever gets 419a/41a4 (16795/16805 cycles,
~2400 Hz) from cells 0bf8/0bf7 at 820b/820e, skew or not - the CPU's fine
timebase - and TDXR is written only from 81b8 with sample data.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The supervisor loads the C51 through its mask-ROM loader: window bytes on
40..5e and a strobe on 18 for each four-word group, ~21k OUTs per download,
every one an engine exit while the program was not yet running. LaneHostIo
now takes the window bytes on 58..5e (the transfer's until the program is
in, the mailbox after) and, while the loader sits in its poll loop at
0638-0652, the strobes: four words at 58 or 5c, the strobe in @56, the
loader stepped until it writes @56 back - _commit_rom_group. The bridge
appends each logged window to the bootstrap before anything reads it. The
strobe that completes the bootstrap, the checksum strobe and anything outside
the loop stay in Python. COURIER_NATIVE_BOOT=0 turns it off.
The 403 link pair is identical apart from the new boot_strobes_native count
(7076 and 7077). The boot's writes into Python drop from 21936 to 704. A live
7900 call took both downloads natively (14155 strobes, bootstrap matched).
Also: COURIER_LANE_CAPTURE=PATH records the data lanes' traffic (word
commits, receive acknowledgements, lane reads) for decoding the frames the
two processors exchange, and SipLine reports its receive underruns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mid-call overlay goes to the C51 as one OUT 1e per four bytes, and each
`2` commits a group to the resident loader. In Python every one cost an
engine exit and a pass through bridge.write - ten thousand in a row, a
260-300 ms stall about 4 s into a live call, with RTP stopped.
LaneHostIo now serves those strobes itself while the overlay port is in
its steady state (active, destination known): it logs each half, and for a
`2` presents the window's four words, rings INT2 and steps the loader until
ff62 moves on, as _commit_overlay_group does, keeping the status byte. The
bridge replays the log through _accumulate_overlay before anything reads
the overlay state. The start/end `4` and anything unusual stay in Python.
COURIER_NATIVE_OVERLAY=0 turns it off.
The 403 link pair is identical with it on and off apart from the new
overlay_strobes_native count (10048 and 10047 strobes). On a live 7900 call
from tower the worst in-call lag drops from 261 ms to 69 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a call that is through and steady (answered, both ends off hook,
nothing ringing, the DAA past dialling, window 1, codec registers
unchanged) a line service that completes one frame now does
_service_line_frame natively: the frame is cut from a native copy of the
exchange buffer, sent and the far end's frame received on the line's
socket, and the received audio queued to the codec with the same peaks,
in-flight copy, DAA counts and recordings, all handed back with the rest.
Every check is made before the send. If the socket fails the service is
taken back and LineLink.exchange is told (_presend) that its frame
already went out, so Python's redo meets the same failure without
sending twice - the I-modem closing the line at the end of the x2 call
takes this path. The frame exchange is armed only when the buffer is
within 48 samples of a frame; COURIER_NATIVE_FRAMES=0 turns it off.
About 3.5k of the call's 6.5k frames run natively. Bit-identical on the
x2 call; wall time is unchanged within noise, because the frame's cost
is mostly the wait for the I-modem's reply, which native code does not
remove. New tests for LineLink's presend handling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A line service whose batch of codec samples does not fill a line frame -
most of them: 68k a call, 6.5k exchange a frame - is now done by
courier_worker_poll: _take_line_audio converts the samples on the
resampler's native retuned state, after a dry run that is rolled back if
a frame would fall due, and the service's statistics, exchange buffer
and cursors are kept in the shared structure and handed back with the
rest. A clock change inside the batch, a rate the resampler is not tuned
to, no codec clock, or a resampler that has not retuned yet stay with
Python, as do the frame exchanges themselves.
49k of the 68k line services run natively; native worker polls 280k ->
330k. The x2 call, a Bell 103 call and a V.34 dial are bit-identical;
wall 27.5 s -> 26.2 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once BandLimitedResampler retunes, its time-stamped history and the
scalars beside it now live in resample::Timed, and _convert_retuned runs
there end to end (seeded from the Python state at the first retune). A
conversion can be rolled back before it is committed, which the worker's
native line service will use. The pure-Python path is unchanged and is
what COURIER_NATIVE_RESAMPLE=0 runs; the native-versus-Python test now
covers the native state across five rate changes. Full x2 call
bit-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Poll elision needed an answered call: BriNetwork.quiet_until answered
only for an active call, _update_elision wanted the peer answered and the
call's channel fed ahead, and the native poll wanted a channel. Before
the call (about 245k polls of the x2 call) nothing is fed ahead and each
idle frame is settled as it finishes, so outside an active call the
harness now asks only that no lookahead is set up; quiet_until covers
every call state, declining when a pass would offer an incoming call
(BearerLineLink.offers_call - the line's ringing only changes on a line
frame, which is a full pass) or report the far end gone; and the native
poll takes a poll with no channel when nothing is fed ahead.
Native I-modem polls 880k -> 1.07M; the x2 call, a Bell 103 call and a
V.34 dial are bit-identical. Wall 32.5 s -> 30.2 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The native model's service only exchanged frames that had been fed ahead,
so with no call up (nothing is fed ahead) every frame the C5x finished
stopped for ImodemDsp.service_pending, which exchanged it through the
same native Bearer::exchange a frame at a time. The service now does that
itself when no routed channel could meet an underrun, and
IsdnMachine._advance_dsp uses the advance-then-serve the engine's poll
uses (courier_imodemio_advance_serve). The lookahead mode is published as
soon as a poll changes it. Full x2 call bit-identical; wall 33.6 s ->
32.5 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
courier_worker_poll (c5x_capi.cpp) does what interpreter_service,
fast_service and clock_x86_fast do for a service in which only the DSP,
the clocks and the DSP's frame edge move: the codec-frame, line-sample and
probe tests, the DSP step with the same debt and CPI arithmetic, and the
INT0 frame-edge entry. Python arms it at the start of the batch after each
service of its own when every test of Python-only state comes out the
fast way, with a deadline before a timer's max count (the 80186 timers
advance lazily, as every access to one does first), the board tick, typed
input or the end of the run; the fields come back whenever the engine
returns. End-of-interrupt writes logged in the batch are applied to the
in-service stack before the frame-edge decision and marked, so the replay
leaves the stack alone. A DSP message, the call TDM starting, the loader
loop changing or a DSP error hand the rest of the service back to Python
(resume codes 2 and 3). The engine lends the poll its guard bytes and the
batch's port and memory-mapped write logs; lamp writes that repeat the
latch no longer force a Python poll.
64% of services now run natively. The x2 call, a Bell 103 call and a V.34
dial are bit-identical; the x2 call goes from 37 s to 33.6 s wall time
(CPU 60.7 s -> 56.3 s). COURIER_WORKER_POLL=0 turns it off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CPython's math.sumprod (a triple-length accumulation) is ported so the dot
products match bit for bit; the Python loop stays as the reference and takes
the samples at a clock edge.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
The analog worker's service, split into the head, the clock, the tail and the
interrupt sources it raises, now has a fast path that makes the same tests in
the same order, runs the DSP with one call that also returns what the harness
reads next, and enters the DSP's frame interrupt itself instead of leaving the
engine for the run loop. It declines, before changing anything, whenever a test
says there is work; later tests hand the rest of the service to the original
code. The overlay and ROM loaders' single-stepping loops run natively.
Bit-identical results.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
Take the block-repeat edge on step()'s fast path instead of through the rare
path (a third of the worker's DSP steps are inside RPTB bodies), keep XC's
condition sample in one register, and read the serial backlog and the panel
latch's published answer with one cheap call each. Bit-identical results.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
The harness works out the byte the board's latch at 0x14 reads as and hands
it to the native port model, which serves it until a panel port is written.
Bit-identical results; the worker's polling loop on that port no longer
leaves the x86 engine.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
Share the interrupt controllers, PIT wrap state and service deadlines in a
ctypes PollState, serve the PIC ports and the poll tail natively, and enter
interrupts in the engine. Bit-identical; full call 169 s -> 155 s.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
With a call up on the bearer line, the engine settles PCM frames, feeds the
DSP ahead and advances it at each poll boundary itself, calling Python only
when a timer falls due, a device is touched, or the line clock has a frame to
send. What the skipped polls would have done to the interrupt controller is
done before anything looks at it. Bit-identical on the full call.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
The Am79C30's bearer queues, the frames settled ahead of the DSP and the
exchange of transmitted frames live in native/bearer.hpp, with Python proxies
(native_bearer.py) standing in for the containers; the Python methods stay the
reference and take the frames the native path leaves (underruns). A
differential test runs both on random scripts. Bit-identical on the pair run.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
IN 0x1c/0x1e and the OUT 0x1c/0x1e writes that need nothing from the harness
no longer leave the x86 engine; commits, acknowledgements and replies still
do. The 0x1e accesses are logged natively and replayed into the mailbox's
overlay logs in order before anything else touches them. Bit-identical.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
One native call collects what a DSP service pass reads (status, reply
registers, transmitted octets); PIT counters are skipped until a wrap is due;
the serial pumps frame and slice only when there is something to do; the
T200 walk is skipped when no timer has expired. Results are bit-identical.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
- Am79C30: clock_bearer is split into taking the network side of a frame
and routing it, so the network side of upcoming frames can be settled
ahead of the modem (bearer_take_ahead), refunded if the routing is about
to change (bearer_return_ahead) and finished later, one frame
(bearer_finish_frame) or a run at a time for ordinary routing
(bearer_finish_batch). A generation counter tracks the line and MUX state
the early frames assumed.
- ImodemDsp feeds receive octets a few frames ahead, only during an active
call and only past octets already queued on the call's channel; the
native advance runs through several frames and stops only for a reply, a
full transmit backlog or an empty receive queue.
- Frames are exchanged at the start of every poll and around DSC writes, so
the bearer sees the same octets at the same times as before.
The I-modem's state is bit-identical to the one-frame-at-a-time path apart
from the octets held ahead (checked over 120M, 160M and 250M instructions),
and the full call still connects at 53333 with both payloads intact; full
call 216 s -> 209 s. COURIER_PCM_BATCH=0 turns it off. Adds tests for the
lookahead and bulk finish against clock_bearer.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
- libcourier_c5x: an I-modem port model serving the data lanes' stores,
the 0x18/0x1a status reads and latch writes and the lane window reads
from the DSP's I/O cells, together with the same C5x advance the
harness runs on every access and service pass (with the same read
quantum). It stops, leaving needs_service set, wherever the harness has
to act - a finished PCM frame or a reply to offer - and ImodemDsp
.service_pending performs that work and continues in Python.
- ImodemDsp's ledger and mailbox scalars (dsp_instructions, cycle debt,
PCM cursor, host_pending, tx_ready, consumed, reply writes, lane bytes)
live in a shared ctypes struct that Python and the native model use in
place, so nothing is marshalled per access.
- Status reads advance the C5x only if 32 instructions have passed since
its last advance; the skipped time stays owed. Writes advance exactly.
- The x86 engine hands port models the harness's instruction count;
after-I/O refresh is limited to the mailbox's own ports.
- Single-call getters replace dict-building stats reads on hot paths.
The I-modem's complete state, including every I/O tally, is bit-identical
with the native model on and off (COURIER_NATIVE_IO=0 selects the Python
path). Paired x2 still connects at 53333 with both payloads intact; full
call 250 s -> 216 s. Adds tests for both native port models.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
- x86 engine: serve the analogue board's live data-lane ports (command,
ack, window reads/stores) through a port model in libcourier_c5x, which
works directly on the DSP's I/O cells. Tallies and last-written values
are folded back into the machine's I/O accounting; anything the model
declines still goes to Python.
- Port 0x14 (front-panel latch / board latch) writes are batched and
replayed in order on both modems.
- C5x core: the per-instruction V.8 dispatch probe is a bitmap lookup
instead of a vector scan, and the first-execution tracker is per core.
These ran on every retired instruction.
- I-modem: slimmer per-access DSP advance chain; core PC read through a
tiny getter; faster advance_imodem result handling.
- LineLink: optional COURIER_LINE_WINDOW (frames in flight, default 1 =
unchanged) so the two modem processes can run ahead of each other by the
line's transit delay.
Paired x2 still connects at 53333 with both payloads intact; full call
350 s -> 250 s. Registers, instruction counts and I/O tallies match the
previous build on the 60M control.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
- Analog bridge: run the C5x to its cycle target in one native call
(step_cycles) instead of looping step()+state(), which also skips IDLE
spans; read line_tx_writes/samples and the codec rate through small
native getters instead of building the full serial/codec state dicts;
reuse ctypes buffers on the per-chunk calls.
- Line exchange runs once a useful batch of codec samples has accumulated
(bounded skip, fallback timer credited), not on every service chunk.
- Resampler dot product uses math.sumprod when available.
- x86 native engine retires software INT itself for vectors the harness
marks (I-modem: all vectors), counting them per vector; null vectors and
guarded accesses still fall back to the Python hook.
- advance_timer avoids two 64-bit divisions in the common period-1 case.
- Build the C5x library with -fno-semantic-interposition so calls inside it
skip the PLT and can inline.
Paired x2 (53333) still connects with both payloads intact; the I-modem's
register, interrupt and instruction state is identical to before on the
60M-instruction control. Adds a native-vs-hook INT equivalence test and
updates the audio-rate test double for line_tx_writes().
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
In digital PCM mode an empty queue hands the DSP an idle codeword and every
later octet arrives a frame late. NativeC5x.g711_rx_underruns() and
g711_rx_pending() make that visible; on the I-modem line replay it happens
only twice, both during call setup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
be49c69 gave the core clear_pc_trace() but nothing outside it could call
it; NativeC5x.clear_pc_trace() now does, through courier_c5x_clear_pc_trace.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At 20.16 MHz the V.34 answerer's per-sample echo-canceller update
(~2080 instructions) overruns the 1964-cycle sample budget, and B's TRN
task ran 780 of 1026 passes a frame. At the full oscillator both ends
train through phase 3 and 4, and the dialled pair now reaches
CONNECT .../LAPM/V42BIS once the answerer runs V.42 detection. The
clock is inferred, not measured: TCLKX (DSP pin 96) or CLKMD1/CLKMD2
settles it. The AC01 power-up frame period doubles with it.
The PC trace now carries ACC before each instruction (pc << 48 |
opcode << 32 | ACC), which is what read J out of a4b2/a4ca.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every Courier-family C5x resident programs the primary port identically - 403
and 302 at 0x8090, 2.1.1 at 0x80bd, 2.3.31 at 0x109d - and the sequence says
what the model has to do. SPC goes 0x0008 then 0x40c8, so MCM = 0 and TXM = 0
and the frame edge is external; DXR is primed and the part spins on XRDY
waiting for that edge; IFR is write-1-cleared; and then IMR is written with
0x002a: INT2, TINT and XINT. RINT, bit 4, is not enabled, and `samm @04` - the
only write certain to reach IMR, since `splk @04` is DP-relative - appears
exactly once in each of the 403 and 302 residents.
A cold start confirms it. Parked at 0x813c the 403 has IMR = 002a, SPC = 40c8,
and the mask ROM's dispatch cells hold @65 = 8178 for XINT against @64 = 819d
for RINT, the same unused stub @6a holds for NMI. Only XINT has a handler.
So `serial_receive_interrupt` was raising the right IFR bit for the wrong
reason and gating it on SPC.RRST, the receiver's reset bit, which the 403
never consults. The 2.x residents then show why naming one bit is wrong at
all: they test data 0x012f and, if set, `lamm @04 ; and #ffcf ; or #0010 ;
samm @04` - same frame, service moved to RINT. One edge now latches both, each
behind its own half of the port's reset, and IMR and INTM decide recognition
where the part leaves them.
Three more things the residents reach that the core did not do:
- Recognition ran only from `interrupt()` and the INTM controls, so a flag
that became eligible without a fresh source edge waited for the next one.
The 2.x rewrite of IMR above happens with INTM already clear, and RETE
clears INTM on its way out of a handler. It is checked at every instruction
boundary now, and taking a vector is its own step.
- A repeated instruction was interruptible. RPTC and the repeat pointers are
not in the context shadow, so a vector out of the middle of a block lost the
rest of it; check_nmi has always refused for that reason.
- NMI vectored to a literal 0x0024. Its slot is offset 0x24 inside the same
IPTR-relocated table as every other vector; 0x0024 is only right because the
mask ROM runs with IPTR zero.
And the timer ignored TCR.TSS, so a stopped timer still raised TINT - which
matters here because TINT is the other thing 0x002a enables, and it is what
wakes the IDLE at 0x813b when no frame has arrived yet.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two reporting defects in the same quantity, and the diagnostics needed to
tell where DP actually comes from.
m_st0.dp is held pre-shifted - LDP stores DP<<7 and GET_ADDRESS ORs it
straight into the offset - but two readers treated it as a raw DP:
- The V.8 dispatch capture computed `(m_st0.dp & 0x1ff) << 7`, which keeps
only (DP & 3) << 7 and then shifts that again, landing on a page the
dispatcher never runs on. v8_handler, v8_countdown and v8_flags came back
0 from every dispatch for that reason - 133,790 of them on the answering
end alone - which reads exactly like a state machine spinning on an unset
vector. With the page right, the handler is af12 on the answering end and
ae7d on the originating one.
- state() exported m_st0.dp raw, so every consumer printing `dp` was
printing DP<<7. The answering end's "dp=896" was DP 7.
Added alongside: shadow_dp, the DP an interrupt return is about to reinstate;
last_dp_pc/value/source, where DP was last written and by which instruction;
and stray_cala_pc/target/dp, latching the first CALA whose target leaves the
loaded images, with the DP and target it ran with.
That last one exists because DP cannot be read after the fact here. The
originating end's crash is a CALA to program 0000, and the mask ROM it lands
in rewrites DP itself - `LST #0` at 0676 - so a DP sampled at the end of the
run describes the ROM, not the call. Latched where it happens, the call is:
9f3a cala -> 0000, with DP = 6
so the vector it read is @2f on page 6, data 032f, which holds 0000 on both
ends. The answering end never reaches this call and never makes a stray one.
Why 032f is never written is not answered here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>