Re: C code .vs. Assembly code for Microcontrollers/DSPs ?

bobduff@world.std.com (Robert A Duff)
14 Mar 1996 17:20:56 -0500

          From comp.compilers

Related articles
[19 earlier articles]
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? cdg@nullstone.com (1996-03-08)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? regnirps@aol.com (1996-03-10)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? rjridder@knoware.nl (Robert Jan Ridder) (1996-03-10)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? rfg@monkeys.com (1996-03-14)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? sberg@camtronics.com (1996-03-14)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? bobduff@world.std.com (1996-03-14)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? bobduff@world.std.com (1996-03-14)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? john.r.strohm@BIX.com (1996-03-15)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? cdg@nullstone.com (1996-03-15)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? cdg@nullstone.com (1996-03-16)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? dan@watson.ibm.com (1996-03-16)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? stefan.monnier@lia.di.epfl.ch (Stefan Monnier) (1996-03-16)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? albaugh@agames.com (1996-03-16)
[24 later articles]
| List of all articles for this month |
From: bobduff@world.std.com (Robert A Duff)
Newsgroups: comp.compilers,comp.dsp
Date: 14 Mar 1996 17:20:56 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 96-03-006 96-03-044 96-03-078
Keywords: architecture

Robert Jan Ridder <rjridder@knoware.nl> wrote:
>This is not necessarily the case if you have an optimizing
>compiler. If you want to perform an int by int multiplication to a
>long result you may write:
>
> la = (long)ia * ib;
>
>If you don't write the (long) cast the compiler is forced to do an int
>evaluation of the right part, so you will certainly lose your high
>part. In a straightforward approach the compiler will create internal
>casts to long on the integer operands, calculate the result in long
>precision and assign it. An optimizing compiler however will recognize
>the special case of long = int * int, forget about the casts and
>produce the result just like you want it to. I will not go into the
>issue of standardisation here, but you can see that it not always
>creates an inevitable burden in the end result.


This is a language problem, IMHO. Languages like C and Ada and Pascal
seem to think that integer data types have something to do with the
underlying hardware. That's wrong. The size in bits of the result
should be determined by the size of the operands, and not their
"type". No casts should be needed.


- Bob
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.