C Floating point arithmetic
Ken Turkowski
ken at turtlevax.UUCP
Fri Dec 6 06:31:47 AEST 1985
In article <7849 at ucla-cs.ARPA> jimc at ucla-cs.UUCP (Jim Carter) writes:
> As for short-int-long conversions, I don't know of any machines where
>loading 16 bits into a 32-bit register is any slower than loading 32 bits.
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"?
--
Ken Turkowski @ CIMLINC, Menlo Park, CA
UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken
ARPA: turtlevax!ken at DECWRL.DEC.COM
More information about the Comp.lang.c
mailing list