[net.unix-wizards] shorts vs. ints on a VAX 11/750

ado@elsie.UUCP (Arthur David Olson) (07/16/85)

I noted today that variables in "ex_vis.h" were declared to be type "short"
rather than type "int."  Now my own experience with our VAX 11/750 has been
that it pays to declare (non-array) variables to be "int" rather than "short";
this avoids all sorts of "cvtxx"s at run time, and seems to more than compensate
for the extra memory fetches involved in using "int"s rather than "short"s.
And yet I've got to believe that there was a good reason for using shorts in vi.

If you have insights in to using shorts versus using ints on the VAX 11/750
in general, or shorts versus ints in vi in particular, I'd appreciate hearing
from you.
--
UNIX is an AT&T Bell Laboratories trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks

faustus@ucbcad.UUCP (Wayne A. Christopher) (07/17/85)

> I noted today that variables in "ex_vis.h" were declared to be type "short"
> rather than type "int."  Now my own experience with our VAX 11/750 has been
> that it pays to declare (non-array) variables to be "int" rather than "short";
> this avoids all sorts of "cvtxx"s at run time, and seems to more than 
> compensate for the extra memory fetches involved in using "int"s rather
> than "short"s. And yet I've got to believe that there was a good reason 
> for using shorts in vi.

Well, there isn't any extra overhead with fetching a long as opposed to a
short -- the fetch is always 32 bits. 

> If you have insights in to using shorts versus using ints on the VAX 11/750
> in general, or shorts versus ints in vi in particular, I'd appreciate hearing
> from you.

I can think of a few: if you are using a lot of them, then maybe you are
concerned with space -- with just a few of them probably that isn't a
problem though. Also, in something like vi, which should be pretty portable
and was written on a 16-bit machine, it seems like good style to me to
be clear about whether you want a variable to have 16 or 32 bits -- an
int can be either, depending on what machine you are running on, and you
can get used to thinking of an int as 32 bits and get into trouble when
it isn't...

	Wayne

chris@umcp-cs.UUCP (Chris Torek) (07/20/85)

>Well, there isn't any extra overhead with fetching a long as opposed to a
>short -- the fetch is always 32 bits. 

On a 780, the fetch is actually 64 bits (at least memory->cache---how
wide is the cache->CPU path?).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland