Problem with div (1.9.0, arm7tdmi)

Lewin A.R.W. Edwards larwe@larwe.com
Tue Jul 3 08:20:00 GMT 2001


> > I have been experiencing a very odd bug in div() from newlib 1.9.0 on an
> > arm7tdmi target (using gcc 2.95.2/cygwin). The manifestation of the bug is
> > that subroutines will spontaneously return out of the middle of the
> > routine, or hang, especially on nested div calls. I eventually tracked 
> down
>
>I'm not sure what you mean by "nested div calls" - do you force div() to
>call itself recursively or something strange?

I mean something like:

y = div(a,div(b,c).rem).rem;

This kind of arithmetic is used a lot in filesystems :) The particular code 
where I hit the problem worst was in my CHS<->LBA conversion.

>I'm not an ARM guy, but this sounds like a struct "return by value" problem.
>You need to look at the generated assembly and see if the stack space is
>being reclaimed before the value is used, or something of the sort.

Very similar to Ingo's suggestion; thanks. I'll poke a bit deeper. Just 
wondering if this was a known problem with newlib (it hasn't bitten me on 
other platforms, which is why I was wondering - in fact this code is more 
or less a direct recompile of some old PA-RISC code I wrote).


-- Lewin A.R.W. Edwards
Embedded Engineer, Digi-Frame Inc.
Work: http://www.digi-frame.com/
Tel (914) 937-4090 9am-6:30pm M-F ET
Personal: http://www.larwe.com/ http://www.zws.com/

"Far better it is to dare mighty things, to win glorious triumphs, even 
though checkered by failure, than to rank with those poor spirits who 
neither enjoy much nor suffer much, because they live in the gray twilight 
that knows not victory nor defeat."
(Theodore Roosevelt)




More information about the Newlib mailing list