Re: A83: C compiler for TI83!
Re: A83: C compiler for TI83!
There is no way that a compiler could generate better assembly for the Z80
or other low end processor than even an average assembly programmer could.
On modern CPU's that are pipe lined, it can take alot more knowledge of how
they work to write better code than a compiler, especially if there are more
than two instruction pipes involved. But a good assembly programmer will
write much better code than any compiler could.
The reason for this is simple: who knows more about your code or what you
are trying to write, you or the compiler? You do, of course. A high level
language like C is just an approximation of what you want to do. If you
have a good knowledge of how a certain processor works and are familiar with
assembly language, you will almost always write better assembly than a
compiler can generate. The reason a compiler will beat you is for one of
1) You are not familiar enough with the CPU or hardware to know how to
efficiently optimize it
2) You are not familiar enough with your own code to know what it is really
doing, at the assembly level
3) You are thinking like a compiler and self-compiling the code, and the
compiler is doing a better job, because that's what it is designed to do and
It would not be better to write it in C and optimize the compiled code.
When writting in assembly, you have full control over what you do. To write
the best code, you must think about what you want to do center the design
around the processor/hardware design.
Why work with assembly when you don't need to? The articles and books by
Michael Abrash (among others) demonstrate this very clearly. They show how
a well optimized C routine can be sped up by 10 to 20 times using hand
optimized assembly. That's an improvement. Ever wondered why every time a
faster computer is made, you have to buy it so new programs will run
decently if at all on it? Why DOS ran faster on my 4.77Mhz 8088 w/64k of
ram than Windows 98 does on my 233Mhz Pentium II w/64m of ram? Because
programmers get sloppy and write everything in high level languages.
The Z80 is not designed at all for high level languages. It has few
indexing features (IX and IY), and those are very slow and take up more
space than normal instructions. A C compiler could not do a very good job
of optimizing for the Z80.
On fast machines, it makes sense to develop in C and write time critical
routines in assembly, but only because of the time requirements. For the
83, C would make large, slow programs. Assembly is the only way to go.
Some proof of this is the TI-89/92. They have a 10Mhz 68000 which is a
fairly fast processor. The rom was written in C, and it shows. Many things
are slugish compared to the other 8x calculators, because the roms were
written in hand optimized assembly.
From: John Kugelman <email@example.com>
To: firstname.lastname@example.org <email@example.com>
Date: Sunday, November 08, 1998 10:41 AM
Subject: Re: A83: C compiler for TI83!
>Master M wrote:
>> Generally speaking, high level languages generate sloppy un-optimized
>> code that ttakes up more memory than fully-optimized hand-coded programs.
>> Because of the 83's space limitations, I don't think it would be a good
>> idea to use a C-Compiler
>Though, if you'd move past this 80's mentality, you'll realize that the
>opposite is usually true nowadays. Most compilers can generate *better*
>code than the average assembly programmer. Learning to program in
>assembly does not mean you will automatically write super fast,
>maximally efficient code.
>And besides, even if the compiler isn't very good, it's still much
>better to write in a HLL and then optimize the assembly language output
>after the program works. It's much easier to develop code with a HLL
>than assembly, so why work with assembly when you don't need to?
>John Kugelman. firstname.lastname@example.org
>I believe we can change anything.
>I believe in my dream.
> - Joe Satriani