[comp.lang.c] interchangeability of code and data

dg@lakart.UUCP (David Goodenough) (12/01/88)

From article <1988Nov28.204018.2079@utzoo.uucp>, by henry@utzoo.uucp (Henry Spencer):
> One should remember that dynamic code generation (necessarily into the
> data space) followed by execution of the resulting code can be a very
> valuable technique for things like interpreters.  One can finesse that
> with a "change data to code" system call, but the system-call overhead
> can hurt badly.

I have to smile a tiny little bit (maybe 1% :-) ) at the comments about
separating data and code. Way back when in 1944 (or thereabouts) when
John Von Neumann & Co. were doing things with the Eniac, someone came
up with a rather clever idea: Why not put the programs in the same memory
as the data ....... the rest (as they say) is history. [1]

[1] Don't quote me on this, it's about 10 years since I took the history
of computing course at university - my memory has got a bit rusty over the
years.

Seriously, I can think of one place where allowing dynamic code generation
has saved me (i.e. Self modifying code) - when writing a single step
utility for a nameless 8 bit micro. Trying to do conditional jumps
without S.M.C. would have been horriffic, as it was I just "patched"
a subroutine w/ the conditional jump I was testing and ..... But then
of course, I'm one of those slightly strange programmers that still uses
assembler when the need arises (Can you handle interrupts from 8 uarts
for incoming data at 38.4 Kbaud in C - I didn't think you could.)
-- 
	dg@lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp@harvard.harvard.edu	  	  +---+

gwyn@smoke.BRL.MIL (Doug Gwyn ) (12/02/88)

In article <356@lakart.UUCP> dg@lakart.UUCP (David Goodenough) writes:
>Can you handle interrupts from 8 uarts for incoming data at 38.4 Kbaud
>in C - I didn't think you could.

There are UNIX systems that do!