home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / os2 / programm / 7161 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.5 KB  |  112 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!think.com!enterpoop.mit.edu!bloom-picayune.mit.edu!jawetzel
  3. From: jawetzel@athena.mit.edu (The Rottweiler)
  4. Subject: Re: 32-bit programming using MASM 6.00b
  5. Message-ID: <1992Dec21.173914.8767@athena.mit.edu>
  6. Sender: news@athena.mit.edu (News system)
  7. Nntp-Posting-Host: indra.mit.edu
  8. Organization: Massachusetts Institute of Technology
  9. References: <1992Dec14.131817.14808@athena.mit.edu>
  10. Date: Mon, 21 Dec 1992 17:39:14 GMT
  11. Lines: 99
  12.  
  13. I'd like to thank everyone for the input - it works.  And now for some 
  14. observations.  Use ml with the /c flag unless who have renamed link386 to link
  15. and its first in your path.  Link produces "Relative frame fix-up" errors.
  16. I assume that link is a 16-bit linker and therefore complains about the flat
  17. model.  Use the 32-bit calls (Dos32Write and Dos32Exit).  When using 32-bit
  18. calls, push the arguments on the stack in the opposite order as with 16-bit
  19. OS/2.  Make sure that there is a DGROUP or link386 complains.
  20.  
  21. One pain is that I have to go thru basedef.h and bsedos.h to find the correct
  22. parameters for the system calls.  I guess I'll have to eventually go thru these
  23. headers and convert them all to PROTO statements.  Next I'll start using the 
  24. PROTO/INVOKE combination to clean things up.
  25.  
  26. Just in case anyone is interested, the final version of the hello program with
  27. full segment definitions is included below.  Thanks again for all your help.
  28.  
  29.                         Jake
  30.  
  31. -------------------- hello.asm -------------------------
  32.  
  33.         title    hello.asm
  34.  
  35.         .386
  36.         .387
  37.  
  38. INCLUDE     filecomp.inc
  39.  
  40. cr        equ    0dh
  41. lf        equ    0ah
  42.  
  43. stdin        equ    0
  44. stdout        equ    1
  45. stderr        equ    2
  46.  
  47. DGROUP        group     _DATA,CONST
  48.  
  49. _DATA        segment dword public flat 'DATA'
  50.  
  51. wlen        dword    ?
  52.  
  53. _DATA        ends
  54.  
  55. CONST        segment dword public flat 'CONST'
  56.  
  57. testmess    byte    cr,lf,'Hello World.',cr,lf
  58. testmess_len    equ    $-testmess
  59.  
  60. CONST        ends
  61.  
  62. _TEXT        segment dword public flat 'CODE'
  63.  
  64.         assume    ds:FLAT,ss:FLAT,es:FLAT
  65.  
  66. main        proc    near
  67.  
  68.         push    offset wlen
  69.         push    testmess_len
  70.         push    offset testmess
  71.         push    stdout
  72.         call    Dos32Write
  73.  
  74.         or    eax,eax
  75.         jnz    error
  76.  
  77.         push    eax
  78.         pushd    1
  79.         call    Dos32Exit
  80.  
  81. error:        push    eax
  82.         pushd    1
  83.         call    Dos32Exit
  84.  
  85. main        endp
  86.  
  87. _TEXT        ends
  88.  
  89.         end    main
  90.  
  91.  
  92. -------------------- hello.inc -------------------------
  93.  
  94. externdef    Dos32Write:near
  95. externdef    Dos32Exit:near
  96.  
  97.  
  98. -------------------- hello.def -------------------------
  99.  
  100. NAME Hello WINDOWCOMPAT
  101. DESCRIPTION "OS/2 2.0 Test Program"
  102. PROTMODE
  103. STACKSIZE 4096
  104.  
  105. -------------------- assemble commands  ----------------
  106.  
  107. ml /c /Zi /W3 hello.asm
  108. link386 /NOE /NOD /ALIGN:16 /M /DE 
  109. hello,,,d:\os2\doscalls,hello;
  110.  
  111.  
  112.