I think Rabbit Semiconductor has done a great job with their processors and core modules. I especially like the familiarity of the Z80 based core. Their Dynamic 'C' IDE however leaves a lot to be desired. Although I agree that better support for projects, and other IDE enhancements would be nice, I personally am more concerned with the slightly brain dead, non ANSI C compiler.
This may not be the best forum for the following discussion but it is related.
The compiler manages to generate respectable code for initializing an int variable on the stack
Code:
ld hl, 0x0000 6
ld (sp + 0x00), hl 11
and even a global int.
Code:
ld hl, 0x0000 6
ld (0xB11F), hl 13
However, initializing a long on the stack is a little less respectable.
Code:
ld de, 0x0000 6
ld bc, 0x0000 6
ld h, b 2
ld l, c 2
ld (sp + 0x02), hl 11
ex de, hl 2
ld (sp + 0x00), hl 11
ex de, hl 2
----
42
It could be:
Code:
ld hl, 0x0000 6
ld (sp + 0x02), hl 11
ld hl, 0x0000 6
ld (sp + 0x00), hl 11
----
34
A 19% improvement and in this case easily optimized to:
Code:
ld hl, 0x0000 6
ld (sp + 0x02), hl 11
ld (sp + 0x00), hl 11
----
28 A 33% improvement.
It also gets it right when incrementing an int on the stack.
Code:
ld hl, (sp + 0x04) 9
inc hl 2
ld (sp + 0x04), hl 11
----
22
But the code generated for incrementing a long on the stack is dreadful!
Code:
ld hl, 0x0000 6
add hl, sp 2
ld e, (hl) 5
inc hl 2
ld d, (hl) 5
inc hl 2
ld c, (hl) 5
inc hl 2
ld b, (hl) 5
push bc 10
push de 10
ld de, 0x0001 6
ld bc, 0x0000 6
call L_add 12
ld h, b 2
ld l, c 2
ld (sp + 0x02), hl 11
ex de, hl 2
ld (sp + 0x00), hl 11
ex de, hl 2
----
108
And without showing the code for the subroutine L_add:
L_add 41
----
149 What the ...?!
This should be:
Code:
ld hl, (sp + 0x00) 9
ld de, 0x0001 6
add hl, de 2
ld (sp + 0x00), hl 11
ld hl, (sp + 0x02) 9
ld de, 0x0000 6
adc hl, de 4
ld (sp + 0x02), hl 11
----
58 A 61% improvement!
Even incrementing a long global variable is frieghtning.
Code:
ld de, (0xB11B) 13
ld bc, (0xB11D) 13
push bc 10
push de 10
ld de, 0x0001 6
ld bc, 0x0000 6
call L_add 12
ld (0xB11B), de 15
ld (0xB11D), bc 15
----
100
L_add 41
----
141
Again, this should be:
Code:
ld hl, (0xB11B) 11
ld de, 0x0001 6
add hl, de 2
ld (0xB11B), hl 13
ld hl, (0xB11D) 11
ld de, 0x0000 6
adc hl, de 4
ld (0xB11D), hl 13
----
66 A 53% improvement!
It's far more efficient, both in clock cycles and memory, to inline the long add than to set up parameters and call a subroutine.
These trivial examples show just how badly the Dynamic C compiler needs work. And this is without mentioning the bugs where it just plain gets it wrong.
In the mean time I would recommend the use of int datatypes where possible and only use long datatypes when absolutely necessary and even then consider using inline asm for inc/decrementing and simple arithmetic. I would also recommend writing all ISRs in assembly.
Perhaps Rabbit Semiconductor could put their efforts into a decent, stand-alone, ANSI C compiler and allow the IDE to become an open source project?
If not I just might be tempted to write my own.
