Wednesday, September 06, 2006
Z8 Compiler - poor optimizations
I'm not very impressed. While the feature set available is quite impressive, when it comes code optimization, the compiler appears to be at the baby level. It's going to be a lot of work if the code isn't quite fast enough, or a bit too bloated for these small microcontrollers. Or maybe I should just work on that forth compiler/interpreter ;-) Or.. switch to the AVR and use GCC. That would be very nice.
I've sent off a request to the support at Zilog. It will be interesting to see how they respond to the issue; -- is the customer service good or bad? I guess I'll find out.
Some of these things I've noticed:
1. The lack of any apparent ability to create normal inline functions. The white-paper indicates they left the 'inline' keyword out of the compiler to prevent code bloat. Unfortunately, leaving it out creates code bloat if you like to create lots of small self-documenting C functions. I may be forced to use ugly #define 'functions' just to get lean and mean assembled code; or perhaps, I'll have to switch to assembly. Yuck.
2. Including assembly instructions that have no effect, for example:
ADD R0, #0 ;; useless
ADC R1, #0 ;; useless
ADC R2, #0 ;; useless
ADC R3, #1 ;; ah. Finally. Something important.
;; Ok, why wouldn't you just use ADD R3, #1?
Wowzie! That's a real pain! :-(
And I was getting kind of excited at the thought of Z8 being programmable with just a few wires...
Then again, for a Neanderthal trapped in FORTH like me, I'm years away from optimized code. Just learned what an inline function is!
No word back yet from Zilog, yet.
The optimization problems aren't the end of the world; it just makes it frustrating because everything else was just so nice. :)
This is also a software problem, the hardware great. I went looking for an alternative Z8 compiler, preferably GPL; I've not found anything yet. I believe SDCC could probably be modified to generate code for it (Anyone know how aggressive it is on optimizations?) I also found another site bemoaning the Z8 compiler woes: http://hrabia.ibib.waw.pl/~winnie/zilog.html
*** And I was getting kind of excited at the thought of Z8 being programmable with just a few wires... ***
It is still very nice. Assembly code on the Z8 isn't that bad -- it's very easy to understand, even if it is still assembly (10 lines of code to do a 1 liner :)
*** Then again, for a Neanderthal trapped in FORTH like me, I'm years away from optimized code ***
Forth can be optimized too. The interpreter/compiler I wrote in the late 80's did peephole and stack reordering optimizations.
a += 0x01000000;
You can also use INT8, and INT16 for 1 or 2 byte integers.
Links to this post: