home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!hamblin.math.byu.edu!yvax.byu.edu!cunyvm!dlvgc
- Newsgroups: comp.os.os2.programmer
- Subject: Re: 32-bit programming using MASM 6.00b
- Message-ID: <92354.221757DLVGC@CUNYVM.BITNET>
- From: Dimitri Vulis <DLVGC@CUNYVM.BITNET>
- Date: Saturday, 19 Dec 1992 22:17:57 EST
- References: <1992Dec14.131817.14808@athena.mit.edu><724545477rommel.root@jonas.gold.sub.org>
- Distribution: world
- Organization: City University of New York/ University Computer Center
- Lines: 113
-
- I too have been trying to write some some OS/2 2.0 code using MASM 6.0b and
- IBM's toolkt20. I've got them to work, which is probably more than some folks
- can say (so I hope this posting is helpful :), but here's what I find strange:
-
- MASM 6 has a convenient PROTO / INVOKE feature, where you tell the assembler
- what kinds of arguments a routine expects and it'll generate the PUSHes in the
- right order for the arguments and a CALL. This is like C's function prototypes.
-
- The header files that come with MASM 6.0B include PROTOs for OS/2 1.x.
- For example, \masm\include\bsedos.inc has the lines:
-
- DosExit PROTO FAR PASCAL \
- fTerminate:BOOL, usExitCode:WORD
-
- but for OS/2 2.0 it should be:
-
- DosExit PROTO NEAR SYSCALL \
- fTerminate:ULONG, usExitCode:ULONG
-
- (I know this by looking at \toolkt20\c\os2h\bsedos.h, of course)
-
- Now, the toolkit also comes with .INC files, but they don't include any PROTOs!
- In fact, \toolkt20\asm\os2inc\bsedos.inc is much smaller than the MASM's one
- and has only structures and the like. Are they maybe trying to be MASM 5
- compatible?
-
- I tried applying H2INC, MokroSog's retarded program for converting
- C .H files into ASM .INC files. It choked right away on some "_Seg16".
-
- So, my question is: is there any way I can get OS/2 _2.0_ function prototypes
- for _MASM_6.0b_ from either IBM or MokroSog? Or is there a more-or-less
- automatic way to get them from the .H files for .C which _are_ included
- with toolkt20? I've been generating them manually, which is ERROR-PRONE!
-
- Here's the program Kai Uwe Rommel posted, somewhat cleaned up, but without
- error-checking still. Note that I have
- set ml=-nologo -Ic:\toolkt20\asm\os2inc -Bllink386
- in config.sys.
-
- .486P
- .model flat,os_os2
-
- includelib os2386.lib
-
- .stack 4000H
-
- OPTION CASEMAP:NONE
-
- ;what's the use... argh!
- INCL_NOCOMMON equ 1
- INCL_DOSPROCESS equ 1
- INCL_DOSFILEMGR equ 1
- INCL_NOPMAPI equ 1
- include OS2.INC
-
- ;why aren't these provided by the above?
-
- CHAR TYPEDEF SBYTE ; ch
- UCHAR TYPEDEF BYTE ; uch
- SSHORT TYPEDEF SWORD ; s
- USHORT TYPEDEF WORD ; us
- LONG TYPEDEF SDWORD ; l
- ULONG TYPEDEF DWORD ; ul
- BOOL TYPEDEF DWORD ; f
- INTEGER TYPEDEF SDWORD ; i ;C INT
- UINT TYPEDEF DWORD ; ui
- PSZ TYPEDEF PTR CHAR
- PCH TYPEDEF PTR CHAR
- PBYTE TYPEDEF PTR BYTE
- PCHAR TYPEDEF PTR CHAR
- PSBYTE TYPEDEF PTR SBYTE
- PSSHORT TYPEDEF PTR SSHORT
- PSWORD TYPEDEF PTR SWORD
- PLONG TYPEDEF PTR LONG
- PSDWORD TYPEDEF PTR SDWORD
- PWORD TYPEDEF PTR WORD
- PULONG TYPEDEF PTR ULONG
- PDWORD TYPEDEF PTR DWORD
- PVOID TYPEDEF PTR
- SHANDLE TYPEDEF USHORT ; sh
- HANDLE TYPEDEF PVOID ; sh
- HFILE TYPEDEF SHANDLE ; hf
- PHFILE TYPEDEF PTR HFILE
-
- DosWrite PROTO NEAR SYSCALL \
- hf:HFILE, bBuf:PVOID, cbBuf:LONG, pcbBytesWritten:PULONG
-
- DosExit PROTO NEAR SYSCALL \
- fTerminate:ULONG, usExitCode:ULONG
-
- EXIT_PROCESS equ 1
- stdout equ 1
-
- ;
-
- .data
- message DB 'Bill Gates sucks a 3.5" floppy!', 13, 10
-
- .data?
- count DD ?
-
- .code
- main proc
- invoke DosWrite,stdout,offset message,lengthof message,offset count
- invoke DosExit,EXIT_PROCESS,0
- main endp
- end main
-
- ---
-
- Dimitri Vulis
-
- Disclaimer: I hate MicroSoft.
-