                       > This is only for MS-DOG users <

Last modification information:
$Header: /cvsroot/xaos/XaoS/doc/README.dos,v 1.3 2003/01/23 17:15:46 kovzol Exp $

This is the 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
GNU/Linux.
 Please read following article if you don't know, what this
mean.


FOR USERS OF BORLAND, MICROSOFT OR WATCOM COMPILERS:

This program was developed under DJGPP-GNU C compiler for DOS. This is
>FREE< compiler (you may get it from Simtel), that is _MUCH_ better that
all commercial compilers I know (BCC, Microsoft, Watcom). It is a
completely 32 bit
 C compiler with its own DOS extender. Also
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. Whole
XaosSis done in about 15 000 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 (Assembly syntax bit differs from "normal" DOS 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 initialization
.
	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 saw it first in GCC output
.
	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 support 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:

-------------------------------------------------------------------------------
< LONG CUT >
   ;	
   ;	main()
   ;	
	assume	cs:_TEXT
_main	proc	near
	enter	2,0		# Not required at all, VERY uneffective on Pentium
.
	push	si		# Why these pops? main is the 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@98	# Unnecesary jump to test...
@1@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@98:				# comparing required (one cmp instruction +)
...
	cmp	di,9999
	jl	short @1@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	


Here is a speed comparison of internal XaoS loop at various compilers:

  |            |                                       |                     |
  |compiler    |  options                              |  loops per second   |
  |____________|_______________________________________|_____________________|
  |pgcc2.7.2p  | -O6 -ffast-math -mpentium -frisc      |  5 464 480          |
  |            | -fomit-frame-pointer -funroll-loops   |                     |
  |            | -fopt-reg-use -frisc                  |                     |
  |egcs970828  |  -O3 -ffast-math -mpentium            |  5 405 405          |
  |            |  -fomit-frame-pointer -funroll-loops  |                     |
  |egcs970828  |  -O3 -ffast-math -m486                |  4 807 692          |
  |            |  -fomit-frame-pointer -funroll-loops  |                     |
  |gcc2.6.3    |  -O3 -ffast-math -m486                |  4 233 641          |
  |            |  -fomit-frame-pointer -funroll-loops  |                     |
  |gcc2.7.2.1  | -O3 -ffast-math -m486                 |  4 149 377          |
  |            | -fomit-frame-pointer -funroll-loops   |                     |
  |gpc2.0      | -O3 -ffast-math -m486                 |  3 433 962          |
  |            | -fomit-frame-pointer -funroll-loops   |                     |
  |vc5.0       | (optimalizace na max)                 |  3 060 908          |
  |wc10.0      |  -7 -5 -ol -ol+ -om -op -or -ot -fp5  |  2 222 222          |
  |            |  -fpi87                               |                     |
  |wc10.0      |  -5 -7                                |  2 217 249          |
  |delphi      |                                       |  2 012 012          |
  |plan9       | (v IDE-586,speed+size optim.)         |  1 623 376          |
  |vc1.0       | (v IDE-586,speed+size optim.)         |  1 531 393          |
  |bc4.5       | (v IDE-486,fastest executable)        |  1 455 604          |
  |bc3.1       | (v IDE-386,fastest executable)        |  1 433 070          |
  |gcc2.7.2.1  |  (no optimizations)                   |  1 281 348          |
  |gpc2.0      |  (no optimizations)                   |  1 109 756          |
  |bp7.0       |                                       |  901 713            |
  |tc2.0       | -1 -f87 -O -r -Z -G -a -mt            |  846 511            |
  |bc4.0       | (v IDE-486,speed optimizations)       |  755 857            |
  |bc2.0       |                                       |  716 535            |
  |bc2.0       | -G -O -2 -Z -r                        |  716 535            |
  |tc2.0       |                                       |  546 546            |
  |bc4.0       | (v IDE-486,speed+size optim.)         |  -3.6676456...      |

                      Comparison on Pentium in FP version

  bc is Borland C, bp is Borland Pascal, egcs is development version of
  GNU C,
 gcc is GNU C, gpc is GNU pascal compiler, pgcc is GNU C with
  experimental 
Pentium patches, plan9 is C compiler from plan9, vc is
  Microsoft Visual C
 and wc is Watcom C
.

  Note that this is just a small benchmark. Sometimes situation can be
  different. But it shows that GCC is very well comparable with the
  best
 commercial compilers and in this test it is fastest even it is
  known to
 be weak in floating point optimizations at Intel
  platforms...

  |            |                                      |                     |
  |compiler    |  options                             |  loops per second   |
  |____________|______________________________________|_____________________|
  |gcc2.7.0    | -O3 -ffast-math -fomit-frame-pointer |  925 925            |
  |            |  -funroll-loops                      |                     |
  |cc          | -O                                   |  840 336            |

                          Comparisons on SUN

  |            |                                      |                     |
  |compiler    |  options                             |  loops per second   |
  |____________|______________________________________|_____________________|
  |gcc2.7.0    | -O3 -ffast-math -fomit-frame-pointer |  2 688 172          |
  |            |  -funroll-loops                      |                     |
  |cc          | -O                                   |  2 096 436          |

                          Comparisons on SGI

  |            |                                       |                     |
  |compiler    |  options                              |  loops per second   |
  |____________|_______________________________________|_____________________|
  |pgcc2.7.2p  | -O6 -ffast-math -mpentium -frisc      |  3 464 480          |
  |            | -fomit-frame-pointer -funroll-loops   |                     |
  |            | -fopt-reg-use -frisc                  |                     |
  |egcs970828  |  -O3 -ffast-math -mpentium            |  3 311 258          |
  |            |  -fomit-frame-pointer -funroll-loops  |                     |
  |gcc2.7.2.1  | -O3 -ffast-math -m486                 |  3 250 000          |
  |            | -fomit-frame pointer -funroll-loops   |                     |
  |wc10.0      | -fpi87 -fp5 -5 -7 -ol -ol+ -om -on    |  3 246 753          |
  |            | -or -ot                               |                     |
  |wc10.0      | -5 -7                                 |  3 194 888          |
  |plan9       |                                       |  2 973 176          |
  |gpc2.0      | -O3 -ffast-math -fstrength reduce     |  2 888 888          |
  |            | -fomit-frame pointer -funroll-loops   |                     |
  |gcc2.7.2.1  |  (bez optimalizace)                   |  2 394 736          |
  |gpc2.0      |  (bez optimalizace)                   |  2 219 512          |
  |bc2.0       | -G -O -2 -Z -r                        |  2 166 666          |
  |bp7.0       |                                       |  1 956 947          |
  |tc2.0       | -1 -O -r -G -Z -a -mt                 |  892 156            |
  |tc2.0       |                                       |  846 511            |

                  Comparisons on Pentium in integer version

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

---------------------------------------------------------------------------
Addendum by Zoltan Kovacs, 2003-01-16:

However Micro$oft is the world leading software developer company
(hmm...), XaoS compiled under Microsoft Visual Studio runs 5 times
slower than the Linux version on the same hardware. My father uses his
own HP OmniBook xe4500 with Windows XP and I installed Daylon XaoS for
him under his XP. (Daylon XaoS is a new generation of XaoS compiled
under Windows and is not part of the main stream currently. It is
developed from the CVS source frozen about August 2002.) Well, under XP
in full screen mode (1024x768) I got 5 frames/sec and under Linux in the
same resolution I got 25 with the same hardware... No comment. :-)

End of addendum.
---------------------------------------------------------------------------

GNU LICENSE:

This program and the whole DJGPP compiler are under GNU General Public
License. If this
 is something new for you read COPYING file. Shortly
GNU is an organization making
 free software like DJGPP compiler. Its
name is recursive and means GNU's not Unix!
 Programs under this license
can be freely distributed and modified but still
 under this license.
Also source code MUST be available. There is some ways
 how to avoid
this so making of commercial software under GNU tools is also
 possible.
So look at XaoS homepage (http://xaos.sf.net) and
 get whole sources
archive. (License is included in file COPYING in standard 
distribution.)

LINUX:

This program was originally developed under GNU/Linux operating system.
It is also
 completely free (you may get it from ftp
(ftp://sunsite.unc.edu/pub/Linux for 
example) or on some very cheap
CD-ROM (distributed by for example Infomagic or Red Hat). Linux is a
modern 32 bit Unix clone originally developed for Intel but 
ports for
other architectures (as Atari and Amiga) are also available. It comes 
with complete set of GNU utilities so it is one of the best environments
for
 development. Lots of free applications are available (games: for
example Doom, 
Quake, Abuse, Koules and much more). Trial version called
minilinux can be
 installed into a few (about 7.5) megabytes to your DOS
drive.

---------------------------------------------------------------------------
Addendum by Zoltan Kovacs, 2003-01-23:

Nowadays Linux *is* the most popular open source operating system and is
thought to be the most dynamically growing OS in the world. Many
opponents of Linux have to say that Linux has a bright future and in 10
years it will be the leading OS in the world. Ignoring their opinion,
for programmers Linux is now already the best platform and for XaoS it
is still the main developing OS.

End of addendum.
---------------------------------------------------------------------------

PROBLEMS WITH THIS PROGRAM:

This program is completely 32 bit so if you have buggy DPMI (as Novell
DOS or 
QEMM 7.5 have) it may cause problems. In QEMM case get patches
to 7.53 from
 its FTP site; in Novell case get Linux! Also memory
requirements are bit 
higher than in normal DOS programs. If the program
is too slow, get faster version
 from its homepage at
http://xaos.sf.net. And use lower
 resolution. 

AUTHOR (of the DOS port and most of XaoS routines)
:

I am Jan Hubicka. You may browse my homepage at
http://www.ucw.cz/~hubicka
 for more information 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 a small amount of money to my address
:

Jan Hubicka
Dukeslkych bojovniky 1944
Tabor
390 03
Czech Republic

You may also contact me at email jh@ucw.cz.
