TIL the "switch" keyword in C was originally a PDP-11 assembly helper subroutine in the Unix system library (this was written before the invention of C). It explains everything about C's behavior.
NAME switch -- switch on value
SYNOPSIS (switch value in r0)
jsr r5,switch;
swtab
(not—found return)
swtab: val1; lab1;
valn; labn
..; 0
DESCRIPTION switch compares the value of r0 against each
of the vali; if a match is found, control is
transferred to the corresponding lab. (after
popping the stack once). If no match has been
found by the time a null labi occurs, switch
returns.
And I think that this switch subroutine mirrors one way of compiling the BCPL switchon statement (on which C's switch statement was explicitly modelled), though the BCPL compiler I used in the mid-1970s was smarter if the cases formed a compact integer sequence.
C was based upon B, which was based upon BCPL. Clearly, the Bell Labs crew were trying to give themselves some BCPL goodness, even in assembly language.
And BCPL was desiged as very thin language just to be good enough to write the CPL compiler, it was never planned to be used to write full applications.
> The PDP-11/40 was designed to fit a broad range of applications, from small stand alone situations ... to large multi-user, multi-task applications requiring up to 124K of addressable memory space.
I'm young, and it's crazy to look back and see how far we've come.
For some context, the PDP-11/40 debuted in 1973, and was $40k in 1973 dollars which is $233k inflation adjusted for today.
There wasn't much available for a "home computer" at the time, but the Kenbak-1 might be a good example for comparison of what one would have cost. It was $750, or $4400 inflation adjusted. It had 256 bytes of memory.
I thought on the PDP-11 bytes in a 16 bit word were stored little endian but the 16 bit words in a 32 bit long were stored the other way around so it's a bit of both?
Words are little-endian but the two halves of a long are big-endian. In consistently little-endian, a 32-bit quantity would be stored with the 1's, 256's, 65536's, and 16777216's place bytes in that order, but the PDP-11 puts them in the order 65536 16777216 1 256.
If you want something still usable nowadays, get Unix Programming Environment, and "The C Programming Languge, 2nd Edition".
Both complement each other really well.