www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/05/00:23:46

From: shaman AT nlc DOT net DOT au
Newsgroups: comp.os.msdos.djgpp
Subject: Is djgpp better? Yes!
Date: Thu, 05 Dec 1996 07:35:45 +1100
Organization: NHJ NORTHLINK COMMUNICATIONS
Lines: 156
Distribution: inet
Message-ID: <32A5E0A1.916@nlc.net.au>
Reply-To: shaman AT nlc DOT net DOT au
NNTP-Posting-Host: dialine21.nlc.net.au
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm one of the many coders out there who are wondering wether DJGPP
really is better. Well, now there is proof, thanks to a guy who wrote a
fractal zoomer thingie.

	Just one question: Could I use DJGPP to cross compile to an totally new
OS? Ie: could I modify the startup libs and replace the PC libraries and
be able to created executables for other Intel compatible operating
systems??

	Anyway, just check this out:

   
---------------------------------------------------------------------

                       > This is only for MS-DOG users <
                             (read this carefully)

This is port of my Unix program xaos for MS-DOG called Chappy. It was
done
in djgpp and is licensed by GPL. Original was done on Linux.
Please read following article if you don't know, what this mean.


FOR USERS OF BORLAND OR MICROSOFT COMPILERS:

This program was developed under djgpp-gnu c compiler for dos. This is
*FREE* compiler (you can get it from simtel) that is *MUCH* better than
all commercial compilers I know (BC++, VC++, Watcom). It is completely
32 bit C compiler with its own dos extender. It also has a borland like
user interface, lots of libraries, debugger, profiler, documentation,
Pascal compiler and other stuff available. Main purpose for porting this
program was to show power of this compiler. Xaos wass done in about
10000 lines in C. 
                            >NO ASSEMBLY< 
It is possible in such speed on other compilers? For example following
program


main()
{int i,a=1,b=0;
 for(i=0;i<9999;i++)
	a=a+b,b=2*a;
 printf("%i\n",a);
}

Compiles into: (AT&T Assembly syntax differs a bit from intel/masm
syntax but I hope
it is still readable for you)

	.file	"example.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
	.ascii "%i\12\0"
	.align 2
.globl _main
_main:
	call ___main		#small and fast inicialisation
	movl $1,%eax		#All variables in registers
	xorl %ecx,%ecx
	movl $9998,%edx		#Cycle goes from 9998 to zero instead 0 to 9999
	.align 2,0x90		#body is aligned to fit better in caches...
L11:
	addl %ecx,%eax		#whole body is in just two instructions
	leal (%eax,%eax),%ecx	#do you know this "trick"? I seen it first here
	decl %edx		#test of cycle is at the end, because compiler
	jns L11			#was sure that it will turn more than once
	pushl %eax		#typical calling of printf..new versions 
	pushl $LC0		#experimentally supports passing in registers..
	call _printf		#no libraries available for now..
	addl $8,%esp		#shorter and faster than pops...
	ret

The following is output generated by borland compiler with optimizations
enabled:
   ;	
   ;	main()
   ;	
	assume	cs:_TEXT
_main	proc	near
	enter	2,0		#not required at all
	push	si		#why are these pushed? main is first function!
	push	di
   ;	
   ;	{int i,a=1,b=0;
   ;	
	mov	si,1		#just some registers are in memory
	mov	word ptr [bp-2],0
   ;	
   ;	 for(i=0;i<9999;i++)
   ;	
	xor	di,di
	jmp	short @1 AT 98	#unnecesary jump to test...
@1 AT 50:
   ;	
   ;		a=a+b,b=2*a;
   ;	
	mov	ax,si		#5 instructions instead of two.
	add	ax,word ptr [bp-2]#slow memory access required...
	mov	si,ax		
	shl	ax,1
	mov	word ptr [bp-2],ax
	inc	di		#cycle is in normal order...more complicated
@1 AT 98:				#comparing required..(one cmp instruction +)
	cmp	di,9999
	jl	short @1 AT 50
   ;	
   ;	 printf("%i\n",a);
   ;	
	push	si		#calling of printf
	push	offset DGROUP:s@
	call	near ptr _printf
	pop	cx		#another unrequired instruction..
	pop	cx
   ;	
   ;	}
   ;	
	pop	di		#unnecesarry
	pop	si
	leave			#up to now..
	ret	

For more informations read http://www.delorie.com!
If you want use this compiler carefully read its license.


AUTHOR:

I am Jan Hubicka. You may browse my homepage at
http://www.paru.cas.cz/~hubicka
for more informations and software. One of main purposes for making this 
program was to get some money to buy new computer(my 486 is too slow for
XaoS)
but then I decided to release this program freely. But PLEASE if you
want to
help me develop more such software send small amount of money to my
address

Jan Hubicka
Dukeslkych bojovniky 1944
Tabor
390 03
Czech Republic

You may also contact me at email hubicka AT paru DOT cas DOT cz


-- 
                                       . . .   the Lord Shaman
      
------------------------------------------------------------------
                  Pentiums melt in your PC, not in your hand.
          http://www.nlc.net.au/~shaman  or  mailto:shaman AT nlc DOT net DOT au
      
------------------------------------------------------------------

- Raw text -


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