Second milestone - mikpe/pdp10-tools GitHub Wiki

Today the project reached its second milestone: booting a pdp10-elf executable on an unmodified KLH10 PDP-10 full-system emulator. I've written an elf2boot utility which converts ELF executables to "DEC EXE shareable SAVE format" files, which can then be booted by KLH10.

> cat kernel.s
        .text
        .globl  _start
        .type   _start,@function
_start:
        halt    0604460 # "PDP" in DEC SIXBIT
        .size   _start,.-_start
> pdp10-elf-as -o kernel.o kernel.s
> pdp10-elf-ld -o kernel kernel.o
> pdp10-elf-elf2boot -o kernel.exe kernel
> kn10-kl
KLH10 2.0l (MyKL) built Aug 26 2023 16:49:35
    Copyright © 2002 Kenneth L. Harrenstien -- All Rights Reserved.
This program comes "AS IS" with ABSOLUTELY NO WARRANTY.

Compiled for unknown-linux-gnu on x86_64 with word model USEINT
Emulated config:
         CPU: KL10-extend   SYS: T20   Pager: KL  APRID: 3600
         Memory: 8192 pages of 512 words  (SHARED)
         Time interval: INTRP   Base: OSGET
         Interval default: 60Hz
         Internal clock: OSINT
         Other: MCA25 CIRC JPC DEBUG PCCACHE CTYINT EVHINT
         Devices: DTE RH20 RPXX(DP) TM03(DP) NI20(DP)
[MEM: Allocating 8192 pages shared memory, clearing...done]

KLH10# set ld_fmt=h36
   ld_fmt: "c36"  =>  "h36"
KLH10# load kernel.exe
Using word format "h36"...
Loaded "kernel.exe":
Format: DEC-PEXE
Data: 0, Symwds: 0, Low: 01000000, High: 0, Startaddress: 01000
Entvec: 06 wds at 01000
KLH10# trace
Tracing now ON
KLH10# go
Starting KN10 at loc 01000...
 1000: JRST 5,1003      E = 1003
 2002000: JRST 4,604460 E = 604460
[HALTED: Program Halt, PC = 2604460]
KLH10>

We have to start in low memory (section 0), so elf2boot constructs a stub containing an XJRST (the first instruction) with a data block which performs a "far jump" to the ELF entry point in section 2. The second instruction is the ELF entry point's HALT which loads a magic cookie into PC before halting the processor.

KLH10 is one of two popular simulators for the extended PDP-10, KL10B, capable of running the original hardware diagnostics and operating systems. It's effectively the closest we can come to the real thing, without actually having it.