C Floating point arithmetic
Joseph S. D. Yao
jsdy at hadron.UUCP
Wed Dec 18 18:06:14 AEST 1985
In article <984 at turtlevax.UUCP> ken at turtlevax.UUCP (Ken Turkowski) writes:
>However, if an int is a long, and your C compiler does all operations
>on longs, then it takes at least one extra instruction to either sign-
>or zero-extend a short or char to a long. So to add two shorts, you have:
> move16 _a,r0
> ext32 r0
> move16 _b,r1
> ext32 r1
> add32 r1,r0
> move16 r0,_a
>Rather than
> move16 _a,r0
> add16 _b,r0
> move16 r0,_a
>Or
> add16 _b,_a
>Can you say "order of magnitude in speed difference"?
How about:
cvtwl _a,r0
cvtwl _b,r1
addl2 r1,r0
cvtlw r0,_a
Or, better,
addw2 _b,_a
This is legitimate VAX code. Can you say "efficient orthogonal
architecture"? Five times fast? ;-)
[No, Cottrell hasn't converted me. It just happens to be true.
Programs should still be written readably and, consequently,
portably.]
--
Joe Yao hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
More information about the Comp.lang.c
mailing list