Hi,

I'm looking at some old 16bit ASM. There are some C callable functions defined with the following form...

TheParms struc
dw 2 dup (?) ;pushed BP and return address
parm1 dw ?
parm2 dw ?
TheParms ends

public _theFunction
_theFunction proc near

mov ax, TheParm.parm1

...

_theFunction endp

Can anybody tell me how to call this function from ASM?

Thanks,

S.
Posted on 2002-05-09 15:40:41 by Station
If you're trying to call it from Win32 forget about it.

If you're trying to call it from real mode DOS and you're in the same code segment, then just call it normally. If you're in a different code segment then call far.

If the function is _cdecl and there are parameters to pass then you'll have to clean up the stack after calling it.


Other than that I can't help you because I don't think I fully understand your question.
Posted on 2002-05-09 15:59:59 by iblis
Thanks for your response.

I'll be more specific...

I'm calling it from DOS. This bits easy.

However, I don't see how to pass the parameters given that they're in a struct.

Furthermore, passing BP and the return address is over my head. Obviously the function needs to know where to return to yet functions which don't take parameters don't see to require this extra information.

Cheers,

S.
Posted on 2002-05-09 16:19:03 by Station
Looks like a SetJump()-ish function to me. Maybe if you were more clear and explained what the function is supposed to do.

Otherwise try passing it a reference to the struct. Most C programs hardly ever pass a whole structure on the stack.
Posted on 2002-05-09 17:47:00 by iblis
your proc may work if there is a definition like

TheParm equ <.TheParms>

But to ensure your function is initializing bp at all it should be defined with parameters or with locals (at least this is valid for masm6).
Posted on 2002-05-10 05:38:10 by japheth