home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4240 < prev    next >
Encoding:
Text File  |  1992-08-15  |  4.0 KB  |  80 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!orstnews!bionette.CGRB.ORST.EDU!choup
  3. From: choup@bionette.CGRB.ORST.EDU (Ping Chou)
  4. Subject: Re: Can you create OS/2 programs with Turbo Assembler?
  5. Message-ID: <1992Aug16.070544.18334@talon.ucs.orst.edu>
  6. Sender: usenet@talon.ucs.orst.edu (Usenet News admin)
  7. Nntp-Posting-Host: cgrb.orst.edu
  8. Organization: Biological Computing Consortium, OSU, Corvallis, OR.
  9. References: <1992Aug12.222613.14838@usenet.ins.cwru.edu>
  10. Date: Sun, 16 Aug 1992 07:05:44 GMT
  11. Lines: 67
  12.  
  13. In article <1992Aug12.222613.14838@usenet.ins.cwru.edu> bbm@po.CWRU.Edu (Brian B. Mathewson) writes:
  14. >
  15. >I know that Microsoft's MASM 6.0 comes with a file which has all the OS/2 1.x
  16. >calls in it so you can create OS/2 1.x programs.  Is there any way to get
  17. >Borland's Turbo Assembler to do the same thing?
  18. >
  19. >I suppose it would be possible to lay down the calls, but the hard part would
  20. >be getting it to create an .EXE file that OS/2 can run.  Is there a utility
  21. >that let's you create a DOS-type .EXE file (but with OS/2 calls) and change
  22. >it into an OS/2 .EXE program?
  23. >
  24. >What about letting you create 32-bit programs?
  25. >
  26.         1. Must have LINK386 (comes with OS/2 2.0) and OS2386.LIB (in
  27.         Developer's Toolkit).
  28.  
  29.         2. Be aware that 16 bits system calls use Pascal calling
  30.         convention, while 32 bits calls use C calling convention.
  31.         Probably any argument pushed/popped to/from the stack is 4 bytes
  32.         in size for 32 bits system calls.
  33.  
  34.         3. Be aware some system calls will modify certain registers,
  35.         ECX and/or EDX most of the time, when they return.
  36.  
  37.         4. The LINK386 can't recognize one record type in the .OBJ file
  38.         generated by TASM, namely record type 88H. All 88H records have
  39.         to be removed before link. You lose nothing by doing this because
  40.         88H is of COMMENT record.
  41.  
  42.         5. Check the resulting .EXE with EXEHDR (in Toolkit) and you will
  43.         see that all system calls are 16:16 pointers. Look into EXE386.H
  44.         (in Toolkit), find the offset where FIXUP records start, and
  45.         change SOURCE TYPE byte (the second byte) for each record
  46.         corresponding to one system call as the following:
  47.         13H -> 06H
  48.         33H -> 26H
  49.         Study the EXE386.H along with your .EXE for better understanding.
  50.  
  51.         6. Get back a little bit. Since all system calls are NEAR, you
  52.         must use near CALL. But if you decalre system calls as EXTRN NEAR,
  53.         the LINK386 will refuse to link because they are now self-relative
  54.         references. To work around, decalre system calls as EXTRN FAR and
  55.         put them in data segment, load EAX with the 32 bits offset part and
  56.         CALL EAX.
  57.  
  58.         7. However, because OS/2 2.0 still use implicite segmented memory
  59.         management where each segment starts at different 64K boundary,
  60.         beginning from the second 64K (00010000H), any reference to data
  61.         segment in the program will trigger an access violation because
  62.         the offset in a segment always begins from 0. (sorry for this long
  63.         sentence) So, if the CS starts at 00010000H and DS,SS at 00020000H,
  64.         creat a numerical variable that will add 00020000H to an item's
  65.         offset and use this variable in place of the offset. You can
  66.         specify where the CODE and DATA should start in .DEF file.
  67.  
  68.         8. Both EIP and ESP are specified in .EXE header so you don't have
  69.         to do anything about them, and DON'T do anything about them,
  70.         especially the ESP. Directly load ESP with a constant when assuming
  71.         the offset in the stack starts from 0 will trigger another access
  72.         violation.
  73.  
  74.         TASM is not made for OS/2 2.0 although it's much more better than
  75.         MASM in DOS environment. I took the pain as I asked for it, what
  76.         I don't understand is why IBM don't release detailed descriptions
  77.         about all these 32 bits .OBJ, .LIB and .EXE formats to make my
  78.         DEVELOPEMENT FOR THE OS/2 2.0 efforts easier.
  79. Ping
  80.