Comment by colejohnson66

3 years ago

For an older CPU example, x86 (in 16 bit mode) maps the interrupt table at the physical address 0. So to tell the CPU what handler to use for the 0th interrupt, you have to do:

    *(u16)0 = segment // dereference of null!
    *(u16)2 = offset

Granted, most 16 bit OSs were written in assembly, not C, but if you were to write one in C, you’d have this problem.

IIRC, the M68k (which was a popular C target with official Linux support) did the same thing.

For a more recent example, AVR (popularized by Arduino) maps it’s registers into RAM starting at address 0. So, if you wanted to write to r0, you could write to NULL instead. Although one would be using assembly for this, not C.