Code generation bug in h8300-hms cross egcs

Jussi Ylanen jethro@students.cc.tut.fi
Sat Dec 12 16:05:00 GMT 1998


  There seems to be a bug in egcs configured as a cross compiler for the
h8300-hms. When generating absolute address references, egcs uses 16-bit
addresses, which only works if the referenced memory location happens to
reside in the lowest or highest 32 kilobyte area of the available address
space (high bits are sign extended). For H8/300H and H8/300S this is unlikely. 

  Among other things, this bug causes floats not to work. Here's a sample code
to illustrate the point:

int main(void)
{
    volatile float  f=0.0;
    volatile char   s[2]="x";

    while(1) {
        f+=1.0;
    }
}


  Compiled with "h8300-hms-gcc -mh -O3 -S test.c" egcs generates the following
output. All the moves with "@LABEL:16" should contain "@LABEL:24" instead: 

;	GCC For the Hitachi H8/300
;	By Hitachi America Ltd and Cygnus Support
;	release F-1
; -O3

	.h8300h
	.file	"test.c"
	.section .rodata
.LC1:
	.ascii "x\0"
	.align 2
.LC3:
	.float 0.00000000000000000000e0
	.align 2
.LC4:
	.float 1.00000000000000000000e0
	.section .text
	.align 1
	.global _main
_main:
	push.l	er6
	mov.l	er7,er6
	subs	#4,sp
	subs	#4,sp
	mov.l	@.LC3:16,er2    ; << Error!
	mov.l	er2,@(-4,er6)
	mov.b	@.LC1:16,r2l    ; << Error!
	mov.b	r2l,@(-8,er6)
	mov.l	#.LC1+1,er2
	mov.b	@er2,r2l
	mov.b	r2l,@(-7,er6)
.L4:
	mov.l	@(-4,er6),er0
	mov.l	@.LC4:16,er1    ; << Error!
	jsr	@___addsf3
	mov.l	er0,@(-4,er6)
	bra	.L4
	.end


  Tested version was egcs-2.91.60 19981201 (egcs-1.1.1 release). Host system
was Redhat 4.2 Linux Intel with gcc version 2.7.2.3.f.1. 

--
Jussi Ylanen




More information about the Gcc-bugs mailing list