public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* H8300H Tiny
@ 2002-08-10 12:09 Torbjörn Lindh
  2002-08-12 15:12 ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Torbjörn Lindh @ 2002-08-10 12:09 UTC (permalink / raw)
  To: gcc

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? 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-14  8:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-10 12:09 H8300H Tiny Torbjörn Lindh
2002-08-12 15:12 ` Jeff Law
2002-08-13 12:29   ` Torbjörn Lindh
2002-08-14  8:05     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).