Article View: comp.os.msdos.programmer
Article #1276Re: ass'y gurus
From: Arthur Rubin
Date: Wed, 02 Sep 1992 21:08
Date: Wed, 02 Sep 1992 21:08
59 lines
2191 bytes
2191 bytes
In <1992Sep2.1478.12907@dosgate> "gord armstrong" <gord.armstrong@canrem.com> writes:
>Segments ARRRG!
>'C' Compiler: Microsoft C 6.0, Assembler: TASM 2.0
>I'm linking a 'C' and assembler prog together in DOS, and I need
>to pass a pointer from a C prog to an assembler proc. For a SMALL
>model this is not much of a problem since code and data are in the
>same segment, as follows:
> char *ptr; // will use in other modules, make it global
>main()
>{
> ptr=malloc((unsigned int)1024); *ptr=0x55;
> get_value(); // call ass'y routine
> free(ptr);
>}
I don't have TASM, so I can't confirm but the corresponding (correct) MASM
code would be.
MSC 5.1 puts unintialized variables in large model in FAR_BSS, so you might
use that rather than FARDATA, but why bother?
DOSSEG
.MODEL LARGE
public _get_value:proc
extrn _ptr:dword
.DATA
other_var db ?
.CODE
;--------------------------------------------------------
; _get_value
;--------------------------------------------------------
_get_value proc
mov ax,SEG _ptr
mov es,ax
assume es,SEG _ptr
les bx,es:_ptr
assume es,nothing
mov al,es:[bx]
xor ah,ah
call to_integer
ret
_get_value endp
--
Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
My opinions are my own, and do not represent those of my employer.
My interaction with our news system is unstable; if you want to be sure I see a post, mail it.
Technical Details
Message-ID:
<a_rubin.715468121@dn66>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!news.service.uci.edu!beckman.com!dn66!a_rubinReferences:
<1992Sep2.1478.12907@dosgate>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!news.service.uci.edu!beckman.com!dn66!a_rubin Newsgroups: comp.os.msdos.programmer Subject: Re: ass'y gurus Message-ID: <a_rubin.715468121@dn66> From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin) Date: 2 Sep 92 21:08:41 GMT References: <1992Sep2.1478.12907@dosgate> Distribution: comp Nntp-Posting-Host: dn66.dse.beckman.com Lines: 59