On Tue, 23 Mar 1999, Stacy D. Coil wrote:

>    uint32 v;
>    uint32 m;
> #asm
>          mov v, eax
>          mov m, ebx
> #endasm
> 
> 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?

You can't just say "mov v, eax", because that's not being passed through
the compiler.  There's 2 ways you can try it..  prefix the 'v' with an
underscore:

    mov _v,eax

Alternatively, you simply find out where abouts in memory that variable
is, and write there.  For example:

    int c,d;
    c=0x123;
    d=0x456;

Compiles into:

push    bp
mov     bp,sp
push    di
push    si
add     sp,*-4
mov     ax,#$123
mov     -6[bp],ax
mov     ax,#$456
mov     -8[bp],ax

So, you use "mov -n[bp],ax", where n is the offset into the stack of the
variable you want (plus 6 (sizeof(bp)+sizeof(di)+sizeof(si)), in bcc's
case).  So if you've got 3 int's, and 4 char's, and you want the offset of
the 4th char, you say 6+(3*sizeof(int))+(4*sizeof(char)), which works out
to 16.

At least that's how I understand it to work.  Anyone got anything to
add/correct?

Davey

Reply via email to