home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / os2 / programm / 7146 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  4.1 KB

  1. Path: sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!hamblin.math.byu.edu!yvax.byu.edu!cunyvm!dlvgc
  2. Newsgroups: comp.os.os2.programmer
  3. Subject: Re: 32-bit programming using MASM 6.00b
  4. Message-ID: <92354.221757DLVGC@CUNYVM.BITNET>
  5. From: Dimitri Vulis <DLVGC@CUNYVM.BITNET>
  6. Date: Saturday, 19 Dec 1992 22:17:57 EST
  7. References: <1992Dec14.131817.14808@athena.mit.edu><724545477rommel.root@jonas.gold.sub.org>
  8. Distribution: world
  9. Organization: City University of New York/ University Computer Center
  10. Lines: 113
  11.  
  12. I too have been trying to write some some OS/2 2.0 code using MASM 6.0b and
  13. IBM's toolkt20. I've got them to work, which is probably more than some folks
  14. can say (so I hope this posting is helpful :), but here's what I find strange:
  15.  
  16. MASM 6 has a convenient PROTO / INVOKE feature, where you tell the assembler
  17. what kinds of arguments a routine expects and it'll generate the PUSHes in the
  18. right order for the arguments and a CALL. This is like C's function prototypes.
  19.  
  20. The header files that come with MASM 6.0B include PROTOs for OS/2 1.x.
  21. For example, \masm\include\bsedos.inc has the lines:
  22.  
  23. DosExit         PROTO FAR PASCAL \
  24.                 fTerminate:BOOL, usExitCode:WORD
  25.  
  26. but for OS/2 2.0 it should be:
  27.  
  28. DosExit         PROTO NEAR SYSCALL \
  29.                 fTerminate:ULONG, usExitCode:ULONG
  30.  
  31. (I know this by looking at \toolkt20\c\os2h\bsedos.h, of course)
  32.  
  33. Now, the toolkit also comes with .INC files, but they don't include any PROTOs!
  34. In fact, \toolkt20\asm\os2inc\bsedos.inc is much smaller than the MASM's one
  35. and has only structures and the like. Are they maybe trying to be MASM 5
  36. compatible?
  37.  
  38. I tried applying H2INC, MokroSog's retarded program for converting
  39. C .H files into ASM .INC files.  It choked right away on some "_Seg16".
  40.  
  41. So, my question is: is there any way I can get OS/2 _2.0_ function prototypes
  42. for _MASM_6.0b_ from either IBM or MokroSog? Or is there a more-or-less
  43. automatic way to get them from the .H files for .C which _are_ included
  44. with toolkt20? I've been generating them manually, which is ERROR-PRONE!
  45.  
  46. Here's the program Kai Uwe Rommel posted, somewhat cleaned up, but without
  47. error-checking still. Note that I have
  48.  set ml=-nologo -Ic:\toolkt20\asm\os2inc -Bllink386
  49. in config.sys.
  50.  
  51. .486P
  52. .model  flat,os_os2
  53.  
  54.         includelib os2386.lib
  55.  
  56. .stack  4000H
  57.  
  58.         OPTION  CASEMAP:NONE
  59.  
  60. ;what's the use... argh!
  61. INCL_NOCOMMON equ 1
  62. INCL_DOSPROCESS equ 1
  63. INCL_DOSFILEMGR equ 1
  64. INCL_NOPMAPI equ 1
  65.           include OS2.INC
  66.  
  67. ;why aren't these provided by the above?
  68.  
  69. CHAR            TYPEDEF         SBYTE   ; ch
  70. UCHAR           TYPEDEF         BYTE    ; uch
  71. SSHORT          TYPEDEF         SWORD   ; s
  72. USHORT          TYPEDEF         WORD    ; us
  73. LONG            TYPEDEF         SDWORD  ; l
  74. ULONG           TYPEDEF         DWORD   ; ul
  75. BOOL            TYPEDEF         DWORD   ; f
  76. INTEGER         TYPEDEF         SDWORD  ; i  ;C INT
  77. UINT            TYPEDEF         DWORD   ; ui
  78. PSZ             TYPEDEF         PTR CHAR
  79. PCH             TYPEDEF         PTR CHAR
  80. PBYTE           TYPEDEF         PTR BYTE
  81. PCHAR           TYPEDEF         PTR CHAR
  82. PSBYTE          TYPEDEF         PTR SBYTE
  83. PSSHORT         TYPEDEF         PTR SSHORT
  84. PSWORD          TYPEDEF         PTR SWORD
  85. PLONG           TYPEDEF         PTR LONG
  86. PSDWORD         TYPEDEF         PTR SDWORD
  87. PWORD           TYPEDEF         PTR WORD
  88. PULONG          TYPEDEF         PTR ULONG
  89. PDWORD          TYPEDEF         PTR DWORD
  90. PVOID           TYPEDEF         PTR
  91. SHANDLE         TYPEDEF         USHORT ; sh
  92. HANDLE          TYPEDEF         PVOID ; sh
  93. HFILE           TYPEDEF         SHANDLE  ; hf
  94. PHFILE          TYPEDEF         PTR HFILE
  95.  
  96. DosWrite        PROTO NEAR SYSCALL \
  97.                 hf:HFILE, bBuf:PVOID, cbBuf:LONG, pcbBytesWritten:PULONG
  98.  
  99. DosExit         PROTO NEAR SYSCALL \
  100.                 fTerminate:ULONG, usExitCode:ULONG
  101.  
  102. EXIT_PROCESS equ 1
  103. stdout equ 1
  104.  
  105. ;
  106.  
  107. .data
  108. message DB  'Bill Gates sucks a 3.5" floppy!', 13, 10
  109.  
  110. .data?
  111. count   DD   ?
  112.  
  113. .code
  114. main    proc
  115.         invoke DosWrite,stdout,offset message,lengthof message,offset count
  116.         invoke DosExit,EXIT_PROCESS,0
  117. main    endp
  118.         end     main
  119.  
  120. ---
  121.  
  122. Dimitri Vulis
  123.  
  124. Disclaimer: I hate MicroSoft.
  125.