Re: A86: What C-compilers have we got? [82/83/83+/85/86]


[Prev][Next][Index][Thread]

Re: A86: What C-compilers have we got? [82/83/83+/85/86]




The reason to use assembly on the calc is simple: size.  There are not very
many games that could not be done "fast enough" in C (if you have read a lot
of stuff by Michael Abrash, you will have a better idea what I mean).  Most
gmames have a lot of halt's in them, simply because the game is too fast.
Zelda 86 has 5 halt's per main loop, on the frames when it is not redrawing
the tilemap for animated tiles.  But even with Zelda, if you left the
important routines written in assembly and did the game logic in C (which
would make it a LOT easier), it would still probably run at about the same
speed.  The issue here is not speed.  It's size.

Compiled C code for the z80 is going to be a lot larger than the equivalent
hand coded z80.  Take a beginner's large z80 game that is very simple.  The
same program written in C is going to be at least as large, and that is
assuming that it is coded very well.  Everything you see about modern
optimizing compilers is speed, not size.  And that makes the code a lot
larger, too.  I ran out of work ram in Zelda 86, and that was coded
completely in assembly.  Sure, there were some things that could have been
done better, like using the $4000 area and hand relocating some stuff, but
the point is, there isn't all that much room on a calc.  Ok, most of it was
graphics and code, but I'd say there's probably a good 5-7k of actual code.
That's not a lot, but for a calc, that's a significant amount.

Take a game like Nibbles.  Bill Nagel's version was around 2100 bytes I
believe.  That's the version that everyone plays.  I know it was one of his
first programs, so it's no doubt a lot larger than it has to be.  I got
bored one night last year sitting in my dorm room, decided that 2k was far
too large for a Nibbles game, and that I'd never written Nibbles, so I wrote
one.  It was a little under 400 bytes.  I didn't go after optimizing it,
just sat down and spent maybe a couple hours writing it.  This is a good
example of what an experienced assembly coder can do.  I sent it to a few pe
ople, and they obviously had too much free time on their hands, and I think
they got it pretty close to 200 bytes (Jonah, got the final numbers on that?
:)  Now, write an equivalent Nibbles game in C.  Just sit down and write it.
I would expect it to be at least 5k or so.  Maybe more, maybe a little less.
If you are an expert at C and really work on it and get to know the
compiler, maybe, maybe you will be able to get it close to 2k.  But there is
no way you are getting it anywhere near 1k or 400 bytes, much less 200.

> most everyone that wants to program games for the ticalcs that dont want
to
> do it in basic either have to use a not so extensive library in c or in a
c
> like language or learn how to do assembly because most ppl dont want to
> write a translator because its a waste of time as they see it for most ppl
> cuz if ppl want to make programs to run in the native language then they
> should try to learn that language and not another language to do the work
> for them. ppl will probably get mad at me for saying that but its the
truth
> that if they dont wanna use basic and wanna have faster programs with
> graphics, etc then using c doesnt give them the full range of flexibility
> and decreases the speed and increases the size of the programs. plus for
> myself at least it was easier to learn z80 than a lot of languages and it
> was much more fun and rewarding.





Follow-Ups: References: