H8300H Tiny
Torbjörn Lindh
toobii@gopta.se
Sat Aug 10 12:09:00 GMT 2002
Hitachi have generated a number of so called Tiny H8:s, for instance the
H8/3664F. These have an h8300h cpu but are limited to a 64k address
space.
The problem with gcc-3.1 (and as far as I can see, the current cvs version
too) is that if I use h8300 mode, I don't take advantage of the added
instructions, adressing modes etc of the h8300h cpu. But if I use the
h8300h mode the addressing gets far to long:
subs #0x4,er7
mov.l er7,@-er7
should really be
subs #0x4,er7
mov.w r7,@er7
and a piece of code such as:
unsigned char a[5];
void f(void)
{
unsigned char i;
i = 0;
while (i < 5) {
if (a[i])
whatever();
i++;
}
}
generates
sub.b r3l,r3l
l0 mov.b r3l,r2l
extu.w r2
mov.w r2,r0
extu.l er0
mov.l er0,er1
add.l #0xfffbd8,er1
mov.b @er1,r2l
beq l1
jsr @whatever
l1 add.b #0x1,r3l
cmp.b #0x5,r3l
bls l0
whereas I would prefer
sub.b r3l,r3l
l0 mov.b r3l,r2l
extu.w r2
mov.w r2,r0
mov.w r0,r1
add.w #0xfbd8,r1 * Changed
mov.b @er1,r2l
beq l1
...
l1 add.b #0x1,r3l
cmp.b #0x5,r3l
bls l0
(or maybe even save a few register moves, but that is beyond this scope).
This might not seem like a big difference, but when you only have 32k for
your code, every wasted word is bad.
I have looked at the code, and one possible way seems to be to define a
new target that differs slightly from the h8300h target.
Does anyone have alternative suggestions how I should go about this?
More information about the Gcc
mailing list