delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/26/01:22:22

From: firewind <firewind AT metroid DOT dyn DOT ml DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q] using int 0x21 to print text with inline asm
Date: 25 Aug 1997 23:35:29 GMT
Organization: Netcom
Lines: 36
Message-ID: <5tt4s1$o6s@dfw-ixnews5.ix.netcom.com>
References: <19970825180600 DOT OAA29264 AT ladder02 DOT news DOT aol DOT com>
NNTP-Posting-Host: elp-tx2-11.ix.netcom.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Egg brains <eggbrains AT aol DOT com> wrote:
> i can't print text to the string using asm. it prints, but not the stuff i
> want (just a bunch of garbled ascii characters with beeps and stuff.) 
> here is the code i am/was using...

> <-----start----->

> char *myHappy;      /* i have also tried using a character */
  ^^^^^^^^^^^^^^ (1)

> void main()
  ^^^^^^^^^^^ (2)
> {

> myHappy = "Hello, world!";
  ^^^^^^^^^^^^^^^^^^^^^^^^^^ (3)
> asm("movw _myHappy, %dx");
> asm("movb $9, %ah");
> asm("int $0x21");       

> }

> <-----end----->

1: No memory is allocated that this pointer points to.
2: main() -always- returns an int.
3: you're assiging a string to a variable, but this string really has no
   storage allocated for it.

I think also your asm is questionable... is there something wrong with
printf that you can't print strings with it?

-- 
[- 				 firewind	                            -]
[-   email: firewind AT metroid DOT dyn DOT ml DOT org (home), firewind AT aurdev DOT com (work)  -]
[- 	    "You're just jealous because the voices talk to -me-."          -]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019