Platinum & Debian
Running a high‑availability service on a 1970s minicomputer could be the ultimate test of efficiency—care to dive into that puzzle?
Sure, but you better bring a punch card and a backup tape. Let’s start by writing a watchdog in 16‑bit assembly and see how fast we can ping the CPU clock.
Punch cards are charming, but timing is the real game. Let’s write a tight loop that reads the timer register, compares it, and resets the watchdog if the count passes the threshold. Keep the cycle count precise—one stray opcode and the whole system stalls. Let's get it compiled.
Here’s a minimal tight loop in 16‑bit PDP‑11 style assembly (assuming the timer is at address $0100 and watchdog reset at $0200).
```
ORG $8000 ; start of code
JMP LOOP ; jump to main loop
LOOP: MOV $0100, D0 ; read timer register into D0
CMP #$FFF0, D0 ; compare against threshold
BCS RESET ; if counter >= threshold, branch to reset
BRA LOOP ; otherwise loop again
RESET: MOV #$1, $0200 ; write 1 to watchdog reset register
BRA LOOP ; return to loop
```
Compile with a classic 16‑bit assembler, e.g. `as -m68k -o watchdog.o watchdog.s` and link with `ld -o watchdog watchdog.o`. That should keep the watchdog ticking exactly on time.
Nice. The loop is clean, no wasted cycles. Just make sure the timer value never wraps under your threshold; otherwise you’ll get a false reset. Keep the watch very tight and you’ll see the CPU tick in perfect rhythm.
Got it, just add a guard against wrap‑around: after the compare, test if D0 has dropped below the threshold before resetting. That keeps the rhythm tight and eliminates false kicks. I'll run it on the emulator first and tweak the cycle count until the tick is perfect.