public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Dividing by zero does NOT generate exception
@ 2011-03-04 22:14 Quanren Xiong
  2011-03-04 22:41 ` [ECOS] " Grant Edwards
  2011-03-05 13:52 ` [ECOS] " Ilija Kocho
  0 siblings, 2 replies; 12+ messages in thread
From: Quanren Xiong @ 2011-03-04 22:14 UTC (permalink / raw)
  To: ecos-discuss

Hi,

I am using  ECOS 2.0.33.  To my suprise, the following code does NOT
generate an exception.

"int b=1; int c=b/0;" The value in variable c will be 0.

The platform is at91rm9200. I double and triple checked the following
options are on:

CYGSEM_KERNEL_EXCEPTIONS_GLOBAL,
CYGPKG_HAL_EXCEPTIONS,
CYGPKG_KERNEL_EXCEPTIONS.

And CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS is disabled.

I would like an exception being generated.
What am I doing wrong?

Thanks for your helps

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-04 22:14 [ECOS] Dividing by zero does NOT generate exception Quanren Xiong
@ 2011-03-04 22:41 ` Grant Edwards
  2011-03-04 23:21   ` Grant Edwards
  2011-03-05 13:52 ` [ECOS] " Ilija Kocho
  1 sibling, 1 reply; 12+ messages in thread
From: Grant Edwards @ 2011-03-04 22:41 UTC (permalink / raw)
  To: ecos-discuss

On 2011-03-04, Quanren Xiong <xiongqr@gmail.com> wrote:

> I am using ECOS 2.0.33.  To my suprise, the following code does NOT
> generate an exception.
>
> "int b=1; int c=b/0;" The value in variable c will be 0.
>
> The platform is at91rm9200. I double and triple checked the following
> options are on:
>
> CYGSEM_KERNEL_EXCEPTIONS_GLOBAL,
> CYGPKG_HAL_EXCEPTIONS,
> CYGPKG_KERNEL_EXCEPTIONS.
>
> And CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS is disabled.
>
> I would like an exception being generated.

Sorry.

Exceptions are run-time events triggered by code that is executing on
the target.

That snippet _doesn't_generate_any_executable_code_.

> What am I doing wrong?

You're expecting a run-time exception from something that doesn't
actually execute at runtime.

-- 
Grant Edwards               grant.b.edwards        Yow! Kids, don't gross me
                                  at               off ... "Adventures with
                              gmail.com            MENTAL HYGIENE" can be
                                                   carried too FAR!


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-04 22:41 ` [ECOS] " Grant Edwards
@ 2011-03-04 23:21   ` Grant Edwards
  2011-03-05  1:01     ` Quanren Xiong
  0 siblings, 1 reply; 12+ messages in thread
From: Grant Edwards @ 2011-03-04 23:21 UTC (permalink / raw)
  To: ecos-discuss

On 2011-03-04, Grant Edwards <grant.b.edwards@gmail.com> wrote:
> On 2011-03-04, Quanren Xiong <xiongqr@gmail.com> wrote:
>
>> I am using ECOS 2.0.33.  To my suprise, the following code does NOT
>> generate an exception.
>>
>> "int b=1; int c=b/0;" The value in variable c will be 0.

> You're expecting a run-time exception from something that doesn't
> actually execute at runtime.

I think I got that one wrong.  For some reason I convinced myself you
were talking about static variables, but the second initialize isn't
lebal for a static initializer.

Perhaps your processor doesn't generate an exception for integer
divide by zero?

-- 
Grant Edwards               grant.b.edwards        Yow! The PINK SOCKS were
                                  at               ORIGINALLY from 1952!!
                              gmail.com            But they went to MARS
                                                   around 1953!!


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-04 23:21   ` Grant Edwards
@ 2011-03-05  1:01     ` Quanren Xiong
  2011-03-05  1:18       ` Paul D. DeRocco
  0 siblings, 1 reply; 12+ messages in thread
From: Quanren Xiong @ 2011-03-05  1:01 UTC (permalink / raw)
  To: Grant Edwards; +Cc: ecos-discuss

Hi Grant,

The hardware is KwikByte KB9200 board from eCosCentric, which is based
on the ARM9 AT91RM9200 processor. But more RAM and ROM are added.

I am new to the ARM architecture.  Can someone confirm the processor
does NOT generate exception on dividing by 0?

Another odd thing I found is that It does NOT generate bad memory
alignment exception either.
For example, the following code will run just fine:

unsigned int addr=0x00040041;
*(int *)addr=0xFEFEFEFE;

Should it generate a bad alignment exception?

To me, it seems that either all the exceptions are blocked by HAL, or
the hardware does not generate exception at all.  How can I find out
which case is true?

I looked the file vectors.S. Is there any way I can find out any of
the exception handler got invoked by printing out in the console?  Of
course, I can NOT call diag_printf() in vector.S, I mean by doing
something similar but in assembly.  Because I can not do hardware
debuging like using JTAG.

Thanks



On Fri, Mar 4, 2011 at 6:20 PM, Grant Edwards <grant.b.edwards@gmail.com> wrote:
> On 2011-03-04, Grant Edwards <grant.b.edwards@gmail.com> wrote:
>> On 2011-03-04, Quanren Xiong <xiongqr@gmail.com> wrote:
>>
>>> I am using ECOS 2.0.33.  To my suprise, the following code does NOT
>>> generate an exception.
>>>
>>> "int b=1; int c=b/0;" The value in variable c will be 0.
>
>> You're expecting a run-time exception from something that doesn't
>> actually execute at runtime.
>
> I think I got that one wrong.  For some reason I convinced myself you
> were talking about static variables, but the second initialize isn't
> lebal for a static initializer.
>
> Perhaps your processor doesn't generate an exception for integer
> divide by zero?
>
> --
> Grant Edwards               grant.b.edwards        Yow! The PINK SOCKS were
>                                  at               ORIGINALLY from 1952!!
>                              gmail.com            But they went to MARS
>                                                   around 1953!!
>
>
> --
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-05  1:01     ` Quanren Xiong
@ 2011-03-05  1:18       ` Paul D. DeRocco
  2011-03-05 16:10         ` Quanren Xiong
  0 siblings, 1 reply; 12+ messages in thread
From: Paul D. DeRocco @ 2011-03-05  1:18 UTC (permalink / raw)
  To: eCos Discuss

> From: Quanren Xiong
> 
> The hardware is KwikByte KB9200 board from eCosCentric, which 
> is based on the ARM9 AT91RM9200 processor. But more RAM and 
> ROM are added.
> 
> I am new to the ARM architecture.  Can someone confirm the 
> processor does NOT generate exception on dividing by 0?

ARM does division in software, so it's up to the library routine. When I
worked with ARM/eCos a few years ago, division by zero didn't invoke any
exception; I doubt that has changed.

> Another odd thing I found is that It does NOT generate bad 
> memory alignment exception either. For example, the following 
> code will run just fine:
> 
> unsigned int addr=0x00040041;
> *(int *)addr=0xFEFEFEFE;
> 
> Should it generate a bad alignment exception?

Alignment faults can be enabled in register CP15. You should download the
data sheet on the processor from Atmel, and the one on the core itself from
ARM, so you can figure this stuff out.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] Dividing by zero does NOT generate exception
  2011-03-04 22:14 [ECOS] Dividing by zero does NOT generate exception Quanren Xiong
  2011-03-04 22:41 ` [ECOS] " Grant Edwards
@ 2011-03-05 13:52 ` Ilija Kocho
  1 sibling, 0 replies; 12+ messages in thread
From: Ilija Kocho @ 2011-03-05 13:52 UTC (permalink / raw)
  To: ecos-discuss

On 04.03.2011 23:14, Quanren Xiong wrote:
> Hi,
>
> I am using  ECOS 2.0.33.  To my suprise, the following code does NOT
> generate an exception.
>
> "int b=1; int c=b/0;" The value in variable c will be 0.
Maybe the optimizer removes the code. Of course the question is why
compiler does bot complain for div by 0?
Is variable c referenced somewhere by the code?
Hint: Try to declare c  (and b) volatile.

Hope this helps.

// Ilija


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-05  1:18       ` Paul D. DeRocco
@ 2011-03-05 16:10         ` Quanren Xiong
  2011-03-06  7:19           ` Paul D. DeRocco
  0 siblings, 1 reply; 12+ messages in thread
From: Quanren Xiong @ 2011-03-05 16:10 UTC (permalink / raw)
  To: Paul D. DeRocco; +Cc: eCos Discuss

Hi,

On Fri, Mar 4, 2011 at 8:18 PM, Paul D. DeRocco <pderocco@ix.netcom.com> wrote:
>> From: Quanren Xiong
>>
>> The hardware is KwikByte KB9200 board from eCosCentric, which
>> is based on the ARM9 AT91RM9200 processor. But more RAM and
>> ROM are added.
>>
>> I am new to the ARM architecture.  Can someone confirm the
>> processor does NOT generate exception on dividing by 0?
>
> ARM does division in software, so it's up to the library routine. When I
> worked with ARM/eCos a few years ago, division by zero didn't invoke any
> exception; I doubt that has changed.
>
>> Another odd thing I found is that It does NOT generate bad
>> memory alignment exception either. For example, the following
>> code will run just fine:
>>
>> unsigned int addr=0x00040041;
>> *(int *)addr=0xFEFEFEFE;
>>
>> Should it generate a bad alignment exception?
>
> Alignment faults can be enabled in register CP15. You should download the
> data sheet on the processor from Atmel, and the one on the core itself from
> ARM, so you can figure this stuff out.
So the registers controlling exception handling are not set up
correctly during boot-up on my platform.
Given that few pepople complain about it, I would assume it is fixed
in Ecos 3.0. Can anybody point me to the code in Ecos 3.0 ARM9 (or
maybe AT91RM9200)  HAL that does the boot-up initialization? I am
stuck with Ecos 2.0 and have to backport the fix to 2.0.

Thanks,

Quanren



> --
>
> Ciao,               Paul D. DeRocco
> Paul                mailto:pderocco@ix.netcom.com
>
>
> --
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-05 16:10         ` Quanren Xiong
@ 2011-03-06  7:19           ` Paul D. DeRocco
  2011-03-07  8:17             ` Paul D. DeRocco
                               ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Paul D. DeRocco @ 2011-03-06  7:19 UTC (permalink / raw)
  To: eCos Discuss

> From: Quanren Xiong [mailto:xiongqr@gmail.com] 
> 
> So the registers controlling exception handling are not set 
> up correctly during boot-up on my platform. Given that few 
> pepople complain about it, I would assume it is fixed in Ecos 
> 3.0. Can anybody point me to the code in Ecos 3.0 ARM9 (or 
> maybe AT91RM9200)  HAL that does the boot-up initialization? 
> I am stuck with Ecos 2.0 and have to backport the fix to 2.0.

Well, I'm not sure I'd call it "incorrect" in 2.0, or assume it's "fixed" in
3.0, because in a correctly written program it wouldn't matter.

I don't know where this register is set in the HAL, and you could find it as
easily as I could. Or, you could just set the bit at the start of your
application.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-06  7:19           ` Paul D. DeRocco
@ 2011-03-07  8:17             ` Paul D. DeRocco
  2011-03-07 10:03             ` Paul D. DeRocco
                               ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Paul D. DeRocco @ 2011-03-07  8:17 UTC (permalink / raw)
  To: eCos Discuss

> From: Quanren Xiong [mailto:xiongqr@gmail.com] 
> 
> So the registers controlling exception handling are not set 
> up correctly during boot-up on my platform. Given that few 
> pepople complain about it, I would assume it is fixed in Ecos 
> 3.0. Can anybody point me to the code in Ecos 3.0 ARM9 (or 
> maybe AT91RM9200)  HAL that does the boot-up initialization? 
> I am stuck with Ecos 2.0 and have to backport the fix to 2.0.

Well, I'm not sure I'd call it "incorrect" in 2.0, or assume it's "fixed" in
3.0, because in a correctly written program it wouldn't matter.

I don't know where this register is set in the HAL, and you could find it as
easily as I could. Or, you could just set the bit at the start of your
application.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-06  7:19           ` Paul D. DeRocco
  2011-03-07  8:17             ` Paul D. DeRocco
@ 2011-03-07 10:03             ` Paul D. DeRocco
  2011-03-07 10:15             ` Paul D. DeRocco
  2011-03-08  1:32             ` Paul D. DeRocco
  3 siblings, 0 replies; 12+ messages in thread
From: Paul D. DeRocco @ 2011-03-07 10:03 UTC (permalink / raw)
  To: eCos Discuss

> From: Quanren Xiong [mailto:xiongqr@gmail.com] 
> 
> So the registers controlling exception handling are not set 
> up correctly during boot-up on my platform. Given that few 
> pepople complain about it, I would assume it is fixed in Ecos 
> 3.0. Can anybody point me to the code in Ecos 3.0 ARM9 (or 
> maybe AT91RM9200)  HAL that does the boot-up initialization? 
> I am stuck with Ecos 2.0 and have to backport the fix to 2.0.

Well, I'm not sure I'd call it "incorrect" in 2.0, or assume it's "fixed" in
3.0, because in a correctly written program it wouldn't matter.

I don't know where this register is set in the HAL, and you could find it as
easily as I could. Or, you could just set the bit at the start of your
application.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-06  7:19           ` Paul D. DeRocco
  2011-03-07  8:17             ` Paul D. DeRocco
  2011-03-07 10:03             ` Paul D. DeRocco
@ 2011-03-07 10:15             ` Paul D. DeRocco
  2011-03-08  1:32             ` Paul D. DeRocco
  3 siblings, 0 replies; 12+ messages in thread
From: Paul D. DeRocco @ 2011-03-07 10:15 UTC (permalink / raw)
  To: eCos Discuss

> From: Quanren Xiong [mailto:xiongqr@gmail.com] 
> 
> So the registers controlling exception handling are not set 
> up correctly during boot-up on my platform. Given that few 
> pepople complain about it, I would assume it is fixed in Ecos 
> 3.0. Can anybody point me to the code in Ecos 3.0 ARM9 (or 
> maybe AT91RM9200)  HAL that does the boot-up initialization? 
> I am stuck with Ecos 2.0 and have to backport the fix to 2.0.

Well, I'm not sure I'd call it "incorrect" in 2.0, or assume it's "fixed" in
3.0, because in a correctly written program it wouldn't matter.

I don't know where this register is set in the HAL, and you could find it as
easily as I could. Or, you could just set the bit at the start of your
application.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] Re: Dividing by zero does NOT generate exception
  2011-03-06  7:19           ` Paul D. DeRocco
                               ` (2 preceding siblings ...)
  2011-03-07 10:15             ` Paul D. DeRocco
@ 2011-03-08  1:32             ` Paul D. DeRocco
  3 siblings, 0 replies; 12+ messages in thread
From: Paul D. DeRocco @ 2011-03-08  1:32 UTC (permalink / raw)
  To: eCos Discuss

> From: Quanren Xiong [mailto:xiongqr@gmail.com] 
> 
> So the registers controlling exception handling are not set 
> up correctly during boot-up on my platform. Given that few 
> pepople complain about it, I would assume it is fixed in Ecos 
> 3.0. Can anybody point me to the code in Ecos 3.0 ARM9 (or 
> maybe AT91RM9200)  HAL that does the boot-up initialization? 
> I am stuck with Ecos 2.0 and have to backport the fix to 2.0.

Well, I'm not sure I'd call it "incorrect" in 2.0, or assume it's "fixed" in
3.0, because in a correctly written program it wouldn't matter.

I don't know where this register is set in the HAL, and you could find it as
easily as I could. Or, you could just set the bit at the start of your
application.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

end of thread, other threads:[~2011-03-06  7:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-04 22:14 [ECOS] Dividing by zero does NOT generate exception Quanren Xiong
2011-03-04 22:41 ` [ECOS] " Grant Edwards
2011-03-04 23:21   ` Grant Edwards
2011-03-05  1:01     ` Quanren Xiong
2011-03-05  1:18       ` Paul D. DeRocco
2011-03-05 16:10         ` Quanren Xiong
2011-03-06  7:19           ` Paul D. DeRocco
2011-03-07  8:17             ` Paul D. DeRocco
2011-03-07 10:03             ` Paul D. DeRocco
2011-03-07 10:15             ` Paul D. DeRocco
2011-03-08  1:32             ` Paul D. DeRocco
2011-03-05 13:52 ` [ECOS] " Ilija Kocho

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).