[TUHS] Memory management in Dennis Ritchie's C Compiler
pnr at planet.nl
Thu Aug 27 18:37:58 AEST 2020
“In fact Dennis's compiler did not use AID instructions for that purpose.”
Whilst local variables are indeed accessed as an offset from the base pointer, I’m not sure that the above statement is correct. In the V6 compiler (-sp) was certainly used to push arguments to the stack, and when the register allocation overflowed, the interim results were pushed to the stack as well with (-sp).
See c10.c, the case CALL in rcexpr(), the function comarg() and sptab (which is right at the end of table.s)
For interim result pushing/popping I refer to the FS and SS macro’s. Dennis discusses these in his “A tour of the C compiler” paper.
Of course this is all implementational detail, not a core design aspect - as Richard Miller showed in his port to the Interdata architecture (including a port of the Ritchie C compiler). Maybe the sentence should have read: "In fact Dennis's compiler did not rely on having AID instructions for that purpose."
@Warren: at moments like these I really like having the line highlight feature that we discussed before Summer.
More information about the TUHS