Reply to post: Re: "crash-landings[1] we had when I was a programmer was writing self-modifying code."

Q. What's today's top language? A. Python... no, wait, Java... no, C

bombastic bob Silver badge

Re: "crash-landings[1] we had when I was a programmer was writing self-modifying code."

PDP-11 in effect needed you to be able to write to where the code was running in order to efficiently pass parameters.





and MYFUNC would use the old 'PC' value as a frame pointer (from the stack), and do a kind of 'PC cleanup' on the program counter so that you returned to the correct address. Or you could call with 'JSR Rx, MYFUNC' and put the old PC into 'Rx' and use it as a frame pointer. I forget the details, but that's kinda how it worked.

And so, you needed to write the arguments to ARG1 and ARG2 (etc) before doing the function call. they might even be general use memory variables if you're really clever with the design. You could even implement the subroutine call by referencing the actual address you call (the last word in the instruction, I think) as 'ARG1 - 2' and poke that before doing the call (making it a dynamic function call of some sort).

Anyway, this was common in the PDP-11 world. I think DEC was kinda proud you COULD do this. But single-thread only, no recursion...

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019