From: johnl@taugh.com   
      
   According to Scott Lurndal :   
   >I do believe that it would be possible in K&R C.   
   >   
   >Create a static array of bytes with the appropriate   
   >object code to perform the operation followed   
   >by a RET instruction. Cast the address   
   >of the array to a function pointer and call it.   
   >   
   >Or take the address of a branch label in an unreachable   
   >point in a function (e.g. after a return), overwrite   
   >the text at that label with the necessary object code   
   >then branch to it (text was generally RW in the K&R days,   
   >eg on the PDP-11).   
      
   Sometimes. On most of the PDP-11s that ran Unix, the 11/45, /70, and   
   /44, user programs had separate instuction and data mappings. The   
   smaller ones, the 11/34, /40, and /60 didn't.   
      
   We knew it was possible to do runtime code generation, since it's an   
   ancient technique widely used by sort programs to speed up the inner   
   comparison loop, but we had enough trouble getting our programs to   
   work the normal way.   
      
      
      
      
      
      
   --   
   Regards,   
   John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for   
   Dummies",   
   Please consider the environment before reading this e-mail. https://jl.ly   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|