The easiest way to do this is to compile up your C function
without the #asm and look at the assembly code that is generated.  The 
-S option is used for this.

Keep in mind that variables fall into two classes:  function local
and global.  In the code you submitted, the variables are all local.
Bcc uses negative offsets from ebp to access them.  The first one
is accessed at -10h[ebp].  Thus, instead of

        mov     v,eax

you would use

        mov     -10h[ebp],eax

The next local variable is a longword further off the stack, that is
-14h.  Again, write a simple program and look at the BCC output to
know for sure.

The global variables are accessed using their name with an underscore prepended.
Thus, to access global int a:

        mov     eax,[_a]

Look at generated BCC output.  That's how I came up with this!

Greg


On Tuesday, March 23, 1999 1:08 PM, Stacy D. Coil [SMTP:[EMAIL PROTECTED]] wrote:
> Please excuse the slight off topic question.  I am trying to use bcc for a
> couple of small routines.  There needs to be some assembly in it, and I
> need to pass arguments back and forth.  I tried the following:
> 
> #define BDOOR_MAGIC  0x564D5868
> #define BDOOR_CMD_GETVERSION           10
> #define BDOOR_PORT   0x5658
> 
> typedef unsigned short uint16;
> typedef unsigned uint32;
> 
> 
> 
> 
> void
> getVersion(version, magic)
> uint32 *version; uint32 *magic;
> {  
>    uint32 v;
>    uint32 m;
>    
> 
> #asm
>          push eax
>          push ebx
>          push ecx
>          push edx
>          
>          mov eax, BDOOR_MAGIC
>          mov ecx, BDOOR_CMD_GETVERSION
>          mov dx, BDOOR_PORT
>          in eax, dx
>          mov v, eax
>          mov m, ebx
>          
>          pop edx
>          pop ecx
>          pop ebx
>          pop eax
> #endasm
>   
>    *version = v;
>    *magic = m;
>    
> }
> 
> But this returns and no symbol for v and m.  Could someone be kind enough
> to show me how to pass varibles from c to assembly and back?
> 
> TIA,
> 
> --Stacy

Reply via email to