home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 9049 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  2.1 KB

  1. Path: sparky!uunet!cs.utexas.edu!usc!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!news.service.uci.edu!beckman.com!dn66!a_rubin
  2. Newsgroups: comp.os.msdos.programmer
  3. Subject: Re: ass'y gurus
  4. Message-ID: <a_rubin.715468121@dn66>
  5. From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
  6. Date: 2 Sep 92 21:08:41 GMT
  7. References: <1992Sep2.1478.12907@dosgate>
  8. Distribution: comp
  9. Nntp-Posting-Host: dn66.dse.beckman.com
  10. Lines: 59
  11.  
  12. In <1992Sep2.1478.12907@dosgate> "gord armstrong" <gord.armstrong@canrem.com> writes:
  13.  
  14.  
  15. >Segments ARRRG!
  16.  
  17. >'C' Compiler: Microsoft C 6.0, Assembler: TASM 2.0
  18.  
  19. >I'm linking a 'C' and assembler prog together in DOS, and I need
  20. >to pass a pointer from a C prog to an assembler proc. For a SMALL
  21. >model this is not much of a problem since code and data are in the
  22. >same segment, as follows:
  23.  
  24. >  char *ptr; // will use in other modules, make it global
  25.  
  26. >main()
  27. >{
  28. >  ptr=malloc((unsigned int)1024); *ptr=0x55;
  29. >  get_value();  // call ass'y routine
  30. >  free(ptr);
  31. >}
  32.  
  33.  
  34. I don't have TASM, so I can't confirm but the corresponding (correct) MASM
  35. code would be.
  36.  
  37. MSC 5.1 puts unintialized variables in large model in FAR_BSS, so you might
  38. use that rather than FARDATA, but why bother?
  39.  
  40. DOSSEG
  41. .MODEL LARGE
  42.                 public  _get_value:proc
  43.  
  44.                 extrn   _ptr:dword
  45.  
  46. .DATA
  47. other_var       db      ?
  48. .CODE
  49. ;--------------------------------------------------------
  50. ; _get_value
  51. ;--------------------------------------------------------
  52. _get_value      proc
  53.  
  54.                 mov     ax,SEG _ptr 
  55.                 mov     es,ax
  56.                 assume  es,SEG _ptr
  57.                 les     bx,es:_ptr
  58.                 assume  es,nothing   
  59.                 mov     al,es:[bx]
  60.                 xor     ah,ah
  61.                 call    to_integer
  62.  
  63.                 ret
  64. _get_value      endp
  65.  
  66. --
  67. Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
  68. 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
  69. My opinions are my own, and do not represent those of my employer.
  70. My interaction with our news system is unstable; if you want to be sure I see a post, mail it.
  71.