The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: RKeller on June 23, 2005, 10:10:17 PM

Title: MASM 8.2 and DOS TCP/IP Stack from WATTCP
Post by: RKeller on June 23, 2005, 10:10:17 PM
Am writing a 32-bit DOS application using the University of Waterloo's DOS TCP/IP stack WATTCP.  We just bought the US$55 manual, which uses C Language libraries.  It shows no assembler examples.  Any suggestions or code samples to call WATTCP's C libraries using MASM 8.2?

I think you PUSH appropriate values/pointers onto the stack, then CALL or JMP to the function name.

RK
Title: Re: MASM 8.2 and DOS TCP/IP Stack from WATTCP
Post by: hutch-- on June 24, 2005, 02:19:32 AM
RK,

I don't know if MASM will run under 32 bit DOS as the 32 bit version produces Windows spec PE files. If they do, check the register preservation conventions used with 32 bit DOS as it may not be the same as win32.

If MASM will not run correctly, you could try NASM as it is designed to run on many platforms where MASM is dos/widows specific.
Title: Re: MASM 8.2 and DOS TCP/IP Stack from WATTCP
Post by: Tedd on June 24, 2005, 10:57:18 AM
The usual convention for C is to push the parameters onto the stack (in reverse order)..
Then call the function..
And then clean up the stack afterwards i.e. add esp,(4*number_of_arguments_pushed)

masm's invoke will work fine with this as long as you declare protos for the functions and make the C type
eg. someFunc proto C arg1:DWORD,arg2:DWORD

So then "invoke someFunc,eax,3" will create the following code:

push 3
push eax
call someFunc
add esp,8
Title: Re: MASM 8.2 and DOS TCP/IP Stack from WATTCP
Post by: AeroASM on June 24, 2005, 05:39:35 PM
Don't get confused between the C programming language and the C calling convention. Most C functions nowadays use stdcall.