Date: Fri, 26 Feb 1999 14:12:08 -0500 Message-Id: <199902261912.OAA24117@envy.delorie.com> X-Authentication-Warning: envy.delorie.com: dj set sender to dj AT envy DOT delorie DOT com using -f From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: <7b6qpv$39t$1@news8.svr.pol.co.uk> (andrew AT lemure DOT freeserve DOT co DOT uk) Subject: Re: Generating Machine Code on the fly References: <7b6qpv$39t$1 AT news8 DOT svr DOT pol DOT co DOT uk> Reply-To: djgpp AT delorie DOT com > Is it possible to allocate an area of memory in djgpp using malloc, > fill it full of bytes of machine code, and then, using an asm > statement, push all the registers, call the area of memory as a > subroutine, pop all the registers when that subroutine returns, and > continue running the C program without any damage being done? This is exactly what the stub does :-) so it should work for you. Of course, getting the machine code *right* might not be trivial. > I assume that there would be some kind of limitation on the quantity of > machine code that could be run in this way? You're limited to a few hundred megabytes, probably. Depends on how much memory you can malloc.