On Wed, Sep 1, 2021 at 10:07 AM Ron Natalie <ron@ronnatalie.com> wrote:
I disagree.  TRAP according to the processor handbook was intended to be used for what UNIX calls system calls.    EMT was the emulator trap used to simulate other operating systems on the same hardware.    Oddly, for some reason, all the DEC OSes use EMT instructions for their system calls.   This came in handy when JHU ported BasicPlus from RSTS to UNIX.     That executable could run fine on UNIX because we caught the few EMT traps that mattered to us and simulated them.   The only thing we had to do other than that was to add a "nostack()" system call that got rid of the normal UNIX-maintained stack starting at the address space (RSTS executables like many DEC OSs used a stack that started around 1000).

The various RT-11 emulators use variations on this theme as well, some inside the kernel, some as a signal handler (fast forward 40-odd years and I'm catching the SIGSEGV traps in executing 16-bit code to implement the unix system calls)... It's a very useful and elegant trick that's been oft-repeated.
 
Many of the UNIX signals come straight from PDP-11 traps:  SIGFPE, SIGIOT, SIGSEGV, SIGBUS, SIGILL, SIGEMT. and those traps invoked those signals.

Yes. They seemed to make perfect sense when I encountered them in Unix after growing up on RSTS/e and RT-11 before my first contact with Unix....
 
FPE - floating point exception
ILL - illegal exception (either unknown opcode or CERTAIN of the privileged instructions, others were ignored)
BUS - fatal unibus timeout trap.   Usually an attempt to access a memory/unibus address that doesn't respond, or to do word accesses on odd boundaries.
SEGV - accessing memory not mapped to you
IOT - the IOT instruction
BPT - the BPT instruction
TRAP, EMT - these instructions