Author: Bruce Moreland
Date: 09:15:59 06/12/98
Go up one level in this thread
On June 12, 1998 at 08:17:34, Guido Schimmels wrote:
>I'm going to port my program from 68xxx to x86 soon.
>My current board represantion is 16 bit int, because the 68xxx
>cannot use char values for addressing without type casting.
>The 68020 and higher support autoscaling addressing modes,
>which will be used everytime when addressing arrays with
>elements bigger than 8 bit.
>My question is, how do other architectures deal with the problem.
>I heard PowerPC for example doesn't support autoscaling and
>will have do an extra shift here.
>So should I change all my arrays from int to char when possible ?
If I'm not too concerned about space, I would use an array of ints,
because the compiler will do what it is comfortable with.
Arrays of chars are better than arrays of 16-bit words on the Pentium
and Pentium Pro when running 32-bit programs. I haven't been paying
attention to how arrays of words work on the Pentium II.
Personally, I don't use 16-bit values ("short") at all except as part of
a space-intensive structure, and then I am very careful to align the
structure on a 32-bit boundary, if it contains any 32-bit values, and to
align any 32-bit values on 32-bit boundaries within the structure as
well.
When I have a 16-bit value in a structure like this, I am sometimes
tempted to typedef a new type as a 16-bit word, then use this type
whenever I need to refer to the thing in the structure. The problem
with this is that you get 16-bittedness propagating all over your
program. So it is better, in my opinion, to pass things around as ints,
and let the compiler cast the 16-bit thing for you when you need to take
something out of a packed structure.
It is better to eat sand than to use "short", unless you absolutely have
to.
"char" is a more marginal case, since there are often positive tradeoffs
that accrue when you use them, and the Pentium doesn't puke and stall
like it does with 16-bit words. But personally I don't pass chars
around either, I do the same thing I do with words -- I might use them
in a structure, but I don't make 8-bit types and use them in parameters
and local variables.
Chars don't work so well on the 21164 alpha chip.
I'm a big believer in "int" and "unsigned".
bruce
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.