delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/25/22:03:16

Sender: nate AT cartsys DOT com
Message-ID: <377434E9.CC9EDCDC@cartsys.com>
Date: Fri, 25 Jun 1999 19:03:21 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.10 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: C++ "Hello World" compiling problem
References: <3768D090 DOT 9BA88A6F AT unn DOT ac DOT uk> <7l0luo$s0t$1 AT news3 DOT Belgium DOT EU DOT net>
Reply-To: djgpp AT delorie DOT com

DaXy_II wrote:
> 
> > C:\mark\code>more<greeting.cpp
> > #include <iostream.h>
> >
> > int main() {
> >         cout << "Hello World." << endl;
> >
> >         return 0;
> > }
> 
> This will be a huge exe! Try this
> 
> int cur;
> 
> void putc(char* vid, char ch) {
>     vid[cur++] =
> 
> int main() {
>     char* video;
>     cur = 0 // You could get the cursor pos ...
> 
>     video = (char*)0xB8000; // 0xB0000 for monocrome monitors.
>     while (*message++) {
>         putc(video,*message);
>     }
> }
> 
> And link without the stdlib, almost as small as an asm

Hmm... did you try this?  It won't work in DJGPP; you can't poke
physical memory addresses directly.

And yes, we know that DJGPP generates large executables.  Hello World
doesn't show its best side... but try compiling Emacs with a compiler
that accepts your code above.

Oh, if you want a small Hello World, here you go:

	.org 0x100
	mov ah, 0x9
	mov dx, msg
	int 0x21
	mov ax, 0x4c00
	int 0x21
msg:	
	.db "Hello, world$"

Run djasm on it.


-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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