delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/09/07:39:16

Reply-To: <arfa AT clara DOT net>
From: "Arthur" <arfa AT clara DOT net>
To: "DJGPP Mailing List" <djgpp AT delorie DOT com>
Subject: RE: should i bother learning asm?? or just learn dx?
Date: Sun, 9 Aug 1998 12:38:52 +0100
Message-ID: <000201bdc38a$48725ec0$ab4d08c3@arthur>
MIME-Version: 1.0
Importance: Normal
In-Reply-To: <6qfbov$bv1$1@star.cs.vu.nl>

> Arthur <arfa AT clara DOT net> wrote:
> > ASM is the cream of programming languages. It should be what you
> > always aspire to. However *alas* virtually no game nowadays is pure
> > ASM. What you should do (or what most people do) is get your game
> > working in C/C++ and add processor-heavy features (such as graphics)
> > in ASM.
>
> > Remember always, no matter what anyone else says, that any language
> > (including C) will never be as fast as the same code in optimised
> > ASM. It is just not possible.
>
> But it is possible that the compiler (i.e. GCC) optimizes your
> function in C better than you could think off. That's why you should,
> IMHO, first profile your speed-critical application, and then _try_ to
> optimize in ASM the parts you _think_ can (and should) go faster.
> GCC does a lot in aligning, instruction ordering and other things for
> your CPU, if you give it the right options.

GCC is good at optimising, but the way that C is structured, a fully optimised
program will still not be as optimised as one written in ASM from scratch. For
instance, writing a simple "hello world" program in DJGPP will produce code ~50k in
size with full optimisation. In ASM, you can get it down to less ahan 5k. I once
wrote a program which was 7k long in ASM. The same program in DJGPP was 80k with -O3
and -s on.

> PS. this is not intended to start a (flame)war between C/C++ and ASM
>     coders, but it's just to clarify some more. And I think it's not
>     _necessary_ to know ASM to be a good (game) coder, although I am
>     sure it will be very usefull if you do.

No it's not necessary, and on the PC it's very hard to learn. But note that
professional programmers use hand-optimised ASM frequently - especially in graphics
code and interrupt routines. The Allegro library uses ASM to get some of its routines
up to speed, as do many other libs.

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819

- Raw text -


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