This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: generation of divxu opcode
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: "Dhananjay R. Deshpande" <dhananjayd at kpit dot com>
- Cc: "Sanjiv Kumar Gupta, Noida" <sanjivg at noida dot hcltech dot com>,<gnuh8 at gnuh8 dot org dot uk>, <gcc at gcc dot gnu dot org>
- Date: Fri, 5 Jul 2002 13:55:47 +0100 (BST)
- Subject: RE: generation of divxu opcode
- References: <69595093233BB547BB70CF5E492B63F247941C@sohm.kpit.com>
Dhananjay R. Deshpande writes:
> Hi,
>
>
> > -----Original Message-----
> > From: Sanjiv Kumar Gupta, Noida [mailto:sanjivg@noida.hcltech.com]
> > Sent: Tuesday, July 02, 2002 5:14 PM
> > To: gnuh8@gnuh8.org.uk
> > Subject: generation of divxu opcode
> >
> >
> > Hi,
> >
> > I wonder why h8300-hms-gcc does not generate "divxu" opcode.
> > it rather uses
> > a function call even for 16-bit/8-bit division. Any idea why
> > such behaviour.
>
> >From the H8300 programming manual -
> The divxu instruction divides the contents of a 16-bit register Rd
> (destination register) by the contents of an 8-bit register Rs
> (source register) and stores the result in the 16-bit register
> Rd. The division is unsigned. The operation performed is 16 bits
> ÷ 8 bits -> 8-bit quotient and 8-bit remainder. The quotient is
> placed in the lower 8 bits of Rd. The remainder is placed in the
> upper 8 bits of Rd. Valid results are not assured if division by
> zero is attempted or an overflow occurs.
"Valid results are not assured." Nasty.
> So this instruction cannot be directly used for 16-bit/8-bit
> division. For e.g. if you are dividing 0xFFF0 by 2, then quotient
> is 0x7FF8 which can't be stored in 8 bits, so overflow occurs. So
> divxu.b can only be used for 8-bit/8-bit division.
Right, but that in no way explains why divxu.b is only disabled on
H8300.
Andrew.