delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/03/13:32:01

Message-ID: <36DD7DAD.3FDDFA96@unb.ca>
Date: Wed, 03 Mar 1999 14:21:33 -0400
From: Endlisnis <s257m AT unb DOT ca>
X-Mailer: Mozilla 4.04 [en] (Win95; U)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Re: Generating Machine Code on the fly
References: <7b6qpv$39t$1 AT news8 DOT svr DOT pol DOT co DOT uk>
<199902261912 DOT OAA24117 AT envy DOT delorie DOT com>
<7b7gra$5nh$1 AT news4 DOT svr DOT pol DOT co DOT uk>
<199902270142 DOT UAA26915 AT envy DOT delorie DOT com>
<7b80qg$qm3$1 AT news8 DOT svr DOT pol DOT co DOT uk>
<36d80527 DOT 13423287 AT 158 DOT 152 DOT 254 DOT 68>
<7b9el1$mi9$1 AT news7 DOT svr DOT pol DOT co DOT uk>
<7b9vu9$1fp$1 AT news6 DOT svr DOT pol DOT co DOT uk> <3 DOT 0 DOT 6 DOT 32 DOT 19990303121608 DOT 0092fc00 AT pop DOT globalserve DOT net>
X-Info: BrunNet, Inc. 888-278-6638
Reply-To: djgpp AT delorie DOT com

Paul Derbyshire wrote:

> >char *codehere;     /*void*, char* or what*/
> >codehere=(char *)malloc(100);    /* 100 bytes of code memory */
> >codehere[0]=0xc3;    /*just perform a ret operation for now*/
> >asm(
> >    "call %%ebx"    /* no comma after this */
> >    : /*no ouputs*/
> >    : b (codehere)   );
>
> Why %ebx? Why not let the compiler choose?

    No real reason, actually I can't remember how to do that, and I didn't feel
like looking it up.

> And won't this clobber %eax with output if the "codehere" code returns a
> value?

    That is something to consider, and sometimes, other registers are used.  I
think if the function returns a "long long" it is in edx:eax [I'm not sure
though].

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlisnis AT BrunNet DOT Net
          Endlisnis AT HotMail DOT com



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019