This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Problems with port to Hitex HiCO.SH-4 board.
- From: Francois Retief <fgretief at sun dot ac dot za>
- To: gary dot thomas at mind dot be
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Mon, 21 Jul 2003 19:27:01 +0200
- Subject: Re: [ECOS] Problems with port to Hitex HiCO.SH-4 board.
- Organization: University of Stellenbosch
- References: <200307211317.06166.fgretief@sun.ac.za> <1058789041.14499.132.camel@hermes>
Hello Gary,
On Monday 21 July 2003 14:04, you wrote:
> >
> > It looks to me that the division operation is not working propperly and
> > that the variable never reaches zero. The SH7750 chip has a floating
> > point unit. Can it be that the gcc compiler is using floating point
> > division? The value would get smaller, but never reaches zero. How do
> > I fix this?
>
> There should not be any floating point operations going on at this
> point. I'd suggest looking at the actual code generated for this
> function - maybe it can shed some light.
You are right, I see no floating point operations. (see below) But I don't
quite understand what is going on here. There is also no DIV operation in the
assembler output. Can it be a compiler error? I am using the sh-elf tools
from a sourceware.cygnus.com mirror site. Both the linux and cygwin generated
code show this problem.
$ sh-elf-gcc --version
sh-elf-gcc (GCC) 3.2.1 (eCosCentric)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Is there any particular compiler options I need to take into account for the
SH7750? Currently my Global compiler/linker flags are the following:
CFLAGS="-ml -m4 -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef
-Woverloaded-virtual -ggdb -O2 -ffunction-sections -fdata-sections
-fno-rtti -fno-exceptions -fvtable-gc -finit-priority"
LDFLAGS="-ml -m4 -ggdb -nostdlib -Wl,--gc-sections -Wl,-static"
> What sort of debugging tools do you have available? If you have
> hardware debugging (stepping, breakpoints, etc), perhaps you can
> see what's happening more fully.
Only a serial port and a scope. No hardware debugging, not yet anyway. :-(
Cheers
Francois
-------8<------------------------------------------------8<---------
externC void diag_write_long_num(
cyg_uint64 n, /* number to write */
cyg_ucount8 base, /* radix to write to */
cyg_ucount8 sign, /* sign, '-' if -ve, '+' if +ve */
cyg_bool pfzero, /* prefix with zero ? */
cyg_ucount8 width /* min width of number */
)
{
80027940: 86 2f mov.l r8,@-r15
char buf[32];
cyg_count8 bpos;
char bufinit = pfzero?'0':' ';
80027942: 48 e0 mov #72,r0
80027944: 96 2f mov.l r9,@-r15
80027946: a6 2f mov.l r10,@-r15
80027948: b6 2f mov.l r11,@-r15
8002794a: c6 2f mov.l r12,@-r15
8002794c: 43 6b mov r4,r11
8002794e: d6 2f mov.l r13,@-r15
80027950: 53 6c mov r5,r12
80027952: e6 2f mov.l r14,@-r15
80027954: 30 ed mov #48,r13
80027956: 22 4f sts.l pr,@-r15
80027958: d8 7f add #-40,r15
8002795a: f3 6e mov r15,r14
8002795c: ee 01 mov.l @(r0,r14),r1
8002795e: 68 1e mov.l r6,@(32,r14)
80027960: 18 21 tst r1,r1
80027962: 01 8f bf.s 80027968 <_diag_write_long_num+0x28>
80027964: 79 1e mov.l r7,@(36,r14)
80027966: 20 ed mov #32,r13
char *digits = "0123456789ABCDEF";
/* init buffer to padding char: space or zero */
for( bpos = 0; bpos < (cyg_count8)sizeof(buf); bpos++ ) buf[bpos] =
bufinit;
80027968: 00 ea mov #0,r10
8002796a: 1f e1 mov #31,r1
8002796c: e3 60 mov r14,r0
8002796e: d4 0a mov.b r13,@(r0,r10)
80027970: 01 7a add #1,r10
80027972: 17 3a cmp/gt r1,r10
80027974: fb 8f bf.s 8002796e <_diag_write_long_num+0x2e>
80027976: c8 2c tst r12,r12
80027978: 01 8f bf.s 8002797e <_diag_write_long_num+0x3e>
/* Set pos to start */
bpos = 0;
/* construct digits into buffer in reverse order */
if( n == 0 ) buf[bpos++] = '0';
8002797a: 00 ea mov #0,r10
8002797c: b8 2b tst r11,r11
8002797e: 2f 8f bf.s 800279e0 <_diag_write_long_num+0xa0>
80027980: 30 e1 mov #48,r1
80027982: 01 ea mov #1,r10
80027984: 10 2e mov.b r1,@r14
else while( n != 0 )
{
cyg_ucount8 d = n % base;
buf[bpos++] = digits[d];
n /= base; <<<--- Expecting a DIV opcode here
}
/* set pos to width if less. */
if( (cyg_count8)width > bpos ) bpos = width;
80027986: 4c e0 mov #76,r0
80027988: ee 00 mov.l @(r0,r14),r0
8002798a: a7 30 cmp/gt r10,r0
8002798c: 00 8b bf 80027990 <_diag_write_long_num+0x50>
8002798e: 03 6a mov r0,r10
/* set sign if negative. */
if( sign == '-' )
80027990: e9 50 mov.l @(36,r14),r0
80027992: 2d 88 cmp/eq #45,r0
80027994: 14 89 bt 800279c0 <_diag_write_long_num+0x80>
80027996: ff 7a add #-1,r10
{
if( buf[bpos-1] == bufinit ) bpos--;
buf[bpos] = sign;
}
else bpos--;
/* Now write it out in correct order. */
while( bpos >= 0 )
80027998: 11 4a cmp/pz r10
8002799a: 06 8b bf 800279aa <_diag_write_long_num+0x6a>
8002799c: 1f d8 mov.l 80027a1c <_diag_write_long_num+0xdc>,r8 !
0x800277c0
diag_write_char(buf[bpos--]);
8002799e: a3 60 mov r10,r0
800279a0: 0b 48 jsr @r8
800279a2: ec 04 mov.b @(r0,r14),r4
800279a4: ff 7a add #-1,r10
800279a6: 11 4a cmp/pz r10
800279a8: f9 89 bt 8002799e <_diag_write_long_num+0x5e>
}
800279aa: 28 7e add #40,r14
800279ac: e3 6f mov r14,r15
800279ae: 26 4f lds.l @r15+,pr
800279b0: f6 6e mov.l @r15+,r14
800279b2: f6 6d mov.l @r15+,r13
800279b4: f6 6c mov.l @r15+,r12
800279b6: f6 6b mov.l @r15+,r11
800279b8: f6 6a mov.l @r15+,r10
800279ba: f6 69 mov.l @r15+,r9
800279bc: 0b 00 rts
-------8<------------------------------------------------8<---------
--
Francois Retief
Tel. (021) 808-4472
http://www.esl.ee.sun.ac.za
ESL, Dept. E&E Engineering
Stellenbosch University
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss