Mail Archives: djgpp/1998/06/09/06:19:10
>I looked through the FAQ but didn't find any help for this problem:
look for djgppasm document, it will probably be very useful to you.
>I would like to use a function which is compiled with NASM (and runs
>OK) and have its parameters redirected to registers, such as this code
>(WATCOM C/C++):
>
>void func(long a, long b);
>#pragma aux func "*" parm [esi] [edi]
>
>this means a goes into the ESI register and b goes into EDI, and i can
>use them in the assembly code.
>
>Is there a way to do this in DJGPP without having to resort to
>externally-declared variables, such as i'm doing now?
>
>a = 1;
>b = 1;
>func();
>
>this looks dirty.
it is. normally with variables you pass in func( a, b ), for instance, a and
b are placed on the stack and then func() is called. so from inside your
function you normally do:
_myfunc:
push ebp ; save ebp b/c you have to
mov ebp, esp ; set up what is called "stack frame"
mov esi,[ebp+8] ; I *think* 8 is right, for a.
mov edi,[ebp+12] ; ditto, but again i could be off by 4 (or more) or also have
; them backwards
pop ebp
ret
That's how it happens, I'm not sure what's up with that watcom thing, but
djgpp does have a similar convention for inlining asm, but you probaly don't
want to go there with me (I'm pretty helpless when it comes to the normal
djgpp assembler, I don't use inline asm except what other people write, hehe)
Cheers,
- Calvin -
---
http://www.cadvision.com/frenchc/ (Wig out, peeps.)
B013CD10B7A08EC3B2C8B940018BC133C2AAE2F9FECA75F2B407CD21B80300CD10C3
- Raw text -