Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!ucsd!nosc!cod!murphys From: murphys@cod.NOSC.MIL (Steven P. Murphy) Newsgroups: comp.sys.ibm.pc Subject: Re: Passing pointers in C to 8086 assembler Message-ID: <1076@cod.NOSC.MIL> Date: 27 Apr 88 16:31:07 GMT References: <7759@ihlpa.ATT.COM> Organization: Naval Ocean Systems Center, San Diego Lines: 62 The following example should help if any errors are found let me know (I'm trying to do the same thing) Assume MSC 5.0 & MASM 5.0 small model main() { char msg[12] = "Hello World"; /* 11 char + \0 */ sub(msg); /* C always passes arrays by address */ } DOSSEG .CODE PUBLIC _sub _sub PROC NEAR push bp mov bp,sp push si push di mov ax,DGROUP ; DGROUP is the compiler's name for data seg mov ds,ax ; ds now holds data seg ( just a guarantee) mov si,[bp+4] ; load offset to msg[0] into si ; now ds:si is the full address of msg lodsb ; LOaD String Byte, pointed to by ds:si into al ; lodsb also automaticly increments si to point ; to next byte in msg ; first char is now in al do what you what then lodsb to get next char ; ; suggestion: ; also pass char count and load it into cx then you can ; use the loop instruction's and lodsb's auto increment feature ; to go through the whole string pop di pop si pop bp ret _sub endp end ------------------------------------------- _ _ _ Clarke's law, 2nd varation: ' ) ) ) / / / / . . __ _ /_ "Any sufficiently advanced technology / ' (_(_/_/ (_/_)_/ /_ is indistinguishable from a rigged demo" / ' ------------------------ S. P. Murphy Internet: murphys@cod.nosc.mil UUCP: {ucbvax,hplabs}!sdcsvax!nosc!murphys