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

  1. Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!caen!destroyer!cs.ubc.ca!alberta!nebulus!ttlg!postmaster
  2. From: Nelson.Yu@ttlg.UUCP (Nelson Yu)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re:32 bit programming using MASM 6.00b
  5. Message-ID: <724862369.0@ttlg.ttlg.UUCP>
  6. Date: 20 Dec 92 07:06:24 GMT
  7. Sender: postmaster@ttlg.UUCP
  8. Lines: 129
  9.  
  10. TR>Is there anyone out there who has experience assembling 32-bit OS/2 v2.0
  11. TR>programs using Microsoft's MASM 6.00b.  I thought that I could use the
  12. TR>flat memory model but LINK386 chokes on the object code. LINK386 does not
  13. TR>complain if I use the normal segmented model but the EXE created generates
  14. TR>a 000E trap.
  15.  
  16. TR>Any pointers would be greatly appreciated.
  17.  
  18. TR>      Jake
  19.  
  20. Wow! finally another MASM 6.00b OS/2 programmer. I have had limited success with flat(32 bits) mode programs. I continuously received a "Relative frame fix-up" error along with a "No automatic data segment." I have fixed neither, yet they run most of the time without causing an error.
  21.  
  22. TR>------------- hello.asm ------------------------
  23.  
  24. TR>  title filecomp.asm
  25.  
  26. TR>  .386
  27.  
  28. You alternatively could use .MODEL FLAT,SYSCALL,OS_OS2
  29.  
  30. TR>INCLUDE  hello.inc
  31.  
  32. Add INCLUDELIB OS2.lib or DOSCALLS.lib
  33.  
  34. TR>cr  equ 0dh
  35. TR>lf  equ 0ah
  36.  
  37. TR>stdin  equ 0
  38. TR>stdout  equ 1
  39. TR>stderr  equ 2
  40.  
  41. TR>DGROUP    group  _DATA
  42.  
  43. DGROUP no longer exist in flat mode. All code and data are merged into one 'flat' segment. The 'group' statement does not help, it in fact is the main reason your program fails to run properly.
  44.  
  45. TR>_DATA   segment dword public use32 'DATA'
  46.  
  47. 'use32' changed to 'flat'
  48.  
  49. TR>testmess db cr,lf,'Hello World',cr,lf
  50. TR>testmess_len equ $-testmess
  51.  
  52. TR>wlen  dw ?
  53.  
  54. TR>_DATA  ends
  55.  
  56.  
  57. TR>_TEXT  segment dword public use32 'CODE'
  58.  
  59. TR>main  proc near
  60.  
  61. TR>  push stdout
  62. TR>  push ds
  63. TR>  pushd offset DGROUP:testmess
  64. TR>  push testmess_len
  65. TR>  push ds
  66. TR>  pushd offset DGROUP:wlen
  67. TR>  call DosWrite
  68.  
  69. Use PROTO and INVOKE. They make code easier to read and modify.
  70.  
  71. The prototype
  72. DosWrite  PROTO(FAR??) SYSCALL
  73.           hf:HFILE,bBuf:PVOID,cbBuf:WORD,pcbBytesRead:PWORD
  74.  
  75. The function call
  76. INVOKE    DosWrite,
  77.           1,
  78.           ADDR testmess,
  79.           LENGTHOF testmess,    ;or testmess_len
  80.           ADDR wlen
  81.  
  82.  
  83. TR>  or eax,eax
  84. TR>  jnz error
  85.  
  86. TR>  push 1
  87. TR>  push 0
  88. TR>  call DosExit
  89.  
  90. TR>error:  push 1
  91. TR>  push 1
  92. TR>  call DosExit
  93.  
  94. Another problem is that the procedures/functions in OS2.LIB are still using 16 bit segments therefore some may require thunking(Your API calls are actually addresses of the function in the DLL.
  95. Try using the newer DOSCALLS.LIB, then replace DosWrite with Dos32write.
  96.  
  97. TR>main  endp
  98.  
  99. TR>_TEXT  ends
  100.  
  101. TR>  end main
  102.  
  103.  
  104. TR>------------- hello.inc ------------------------------------
  105.  
  106. TR>externdef DosWrite:near
  107. TR>externdef DosExit:near
  108.  
  109. You at least understand the internal workings of flat mode
  110. programs.
  111.  
  112. TR>------------- hello.def ------------------------------------
  113.  
  114. TR>NAME HELLO WINDOWCOMPAT
  115. TR>DESCRIPTION "OS/2 2.0 Test Program"
  116. TR>PROTMODE
  117. TR>STACKSIZE 4096
  118.  
  119. I noticed in my PM programs written in assembly. They required 8192 bytes of stack space. If you did not meet this requirement, PM rudely send the application a SYS3175? error message.
  120.  
  121. TR>------------- assemble commands --------------------------
  122.  
  123. TR>ml /c /Zi /W3 hello.asm
  124. TR>link386 /NOE /NOD /ALIGN:16 /M /DE
  125. hello,,,c:\os2\doscalls,hello;
  126.  
  127. Nirvana has weeds. MASM 6.00b is still very buggy. I have been search for a suitable replacement with no luck. I personally rather move on to a subject like Object-oriented assembly, but if you prefer to continue on just ask me to post up some more example code.
  128.  
  129.  
  130. ---
  131.  X SLMR 2.1a X
  132. 1200
  133.  
  134. 3
  135. ..
  136. 900
  137.  
  138.  * Origin: Mach2 Vulcan OS/2 Systems 1-403-489-4250 (42:100/20)
  139.