Register short
gea%Romeo at cit-hamlet.arpa
gea%Romeo at cit-hamlet.arpa
Tue Nov 26 17:14:11 AEST 1985
Actually, 'register short' can be a useful construct if your compiler
knows what to do with it. I had a loop doing a checksum and wanted to keep
the sum in a register. If I declared it as 'register int' (this is on a
VAX), I got code looking like:
; R11 = pointer to array of shorts to be checksummed
; R10 = working sum
CVTWL (R11)+,R0
ADDL2 R10,R0
whereas if I declared the sum as 'register short' the loop body was
ADDW2 R10,(R11)+
[Apologies if my assembler syntax isn't perfect, it's been a while -- and I
know these don't produce exactly the same result, but I had a short to store
the checksum in, so the second was actually what I wanted].
The point is that there can be some benefit to compilers supporting
'register short' and 'register char' -- a lot of unnecessary conversions
can be eliminated. (This was done on a VMS machine using INTERactive
Systems' compiler).
Gary Ansok
More information about the Comp.lang.c
mailing list