www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/29/05:57:10

Sender: nate AT cartsys DOT com
Message-ID: <35971747.FD57150F@cartsys.com>
Date: Sun, 28 Jun 1998 21:25:43 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
MIME-Version: 1.0
To: dante AT ctonline DOT it
CC: djgpp AT delorie DOT com
Subject: Re: ASM with DJGPP
References: <35960c15 DOT 2096193 AT news DOT interbusiness DOT it>

Roberto wrote:
> 
> I have two question:
> 1) How can I refer to local variable in inline asm ?
>   If I have a global Variable I do it so:
>   int i;
>   main() {
>       asm("mov _i, %ax");
>           }

You should use GCC's extended asm features for this.  Here's an example
(and the register becomes %eax, because ints are 32 bits):

asm("movl %0, %%eax" 
    : /* no outputs */
    : "g" (i) 
    : "eax"); /* clobbers eax */

For more info, see this great tutorial:

http://www.rt66.com/~brennan/djgpp/djgpp_asm.html

>  2) How can i write the istruction   mov ss:[bp]      in Djgpp ?

Well, you'd say

mov[bwl] something, %ss:(%bp)

Actually, the %ss is redundant; references relative to %(e)bp are always
%ss-relative.

But be warned that this is almost certainly *not* what you want!  DJGPP
programs run in protected mode, and 16-bit addresses are not useful.  In
fact, I'm not even sure if GNU AS supports them properly.  What you
probably want is something more along the lines of:

movl something, (%ebp)  
-- 

Nate Eldredge
nate AT cartsys DOT com


- Raw text -


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