long conversion of short expression.
Paul Guthrie
pdg at chinet.chi.il.us
Fri Jul 28 08:41:34 AEST 1989
Here is a case where 68000 compilers don't seem to agree.
In the following code segment, the two shorts multiplied together
exceed the size of a short, but the question is, is the result
of the multiplication really a short to be converted to a
long, or a long already?
main()
{
short x=0x18,y=0x588;
long z=0x100000;
printf("%lx\n",z+(x*y));
}
Should the compiler generate
move -2(fp),d0
muls -4(fp),d0
extl d0
addl -8(fp),d0
or should the extl instruction be left out? muls has already
generated a long result. Both the Sun and GNU compilers
do not use the extl, but I have seen other compilers that
would.
--
Paul Guthrie
chinet!nsacray!paul
More information about the Comp.lang.c
mailing list