Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Divide by zero

2005-12-31 by Karl Olsen

---- Original Message ----
From: "soren_t_hansen" <soren_t_hansen@...>
To: <lpc2000@yahoogroups.com>
Sent: Saturday, December 31, 2005 12:12 PM
Subject: [lpc2000] Divide by zero

> What happenes if you make a division by zero on the LPC2132? I suspect
> that you enter the Undefined Instruction exception handler, but is
> that correct? I haven't been able to find anything about it in the
> manual.

No, the ARM7TDMI does not have a hardware divide instruction, so divisions
are purely a software matter.

With gcc, the compiler calls __divsi3 and __udivsi3 for signed and unsigned
integer divisions, and they are implemented in libgcc, a part of gcc.  If
you try to divide by zero, they call __div0, and then return 0.  The default
implementation of __div0 does nothing.

Other compilers might handle it differently.

Karl Olsen

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.