> Does anyone have any C coding examples for Windows95/NT or can suggest where> I should continue searching for examples of code which dynamically generates> machine instructions and at some point executes them?>> A JIT compiler would be great but I'm afraid it would be overkill and very> complicated to follow.>> Jim> [Generating code on the fly on an x86 in the usual flat address mode is> easy. Just store the code in malloc'ed memory and jump to it. -John]

Appeared in SIGPLAN Conference on Programming Language Design and
Implementation (PLDI '96), Philadelphia, PA, May 1996.

Abstract

We present vcode, a portable, extensible, very fast dynamic code
generation system. An important feature of vcode is that it
generates machine code ``in-place'' without the use of
intermediate data structures. Eliminating the need to construct
and consume an intermediate representation at runtime makes vcode
both efficient and extensible. vcode dynamically generates code at
an approximate cost of six to ten instructions per generated
instruction, making it over an order of magnitude faster than the
most efficient general-purpose code generation system in the
literature.

Dynamic code generation is relatively well known within the
compiler community. However, due in large part to the lack of a
publicly available dynamic code generation system, it has remained
a curiosity rather than a widely used technique. A practical
contribution of this work is the free, unrestricted distribution
of the vcode system, which currently runs on the MIPS, SPARC, and
Alpha architectures.

I was certain that x86 was supported, but couldn't find anything
except a mention of a port the x86 on the tickc page ('C is a C
variant that uses vcode for dynamic code generation). Looking in the
tcc-1.0b9.tgz distribution has a vcode-x86 directory. Both the vcode
and vcode-x86 in tcc appear to be based on older distributions of
vcode.