Dnia Sun, 25 Mar 2007 01:57:59 +0100, SasQ napisa³(a):
Thanks for everyone for their explanations.
It has cleared me a couple of things.
Now I'll try to sumarize it:
Machine word: sizeof(long int):
8-bit 4 Emulated as four 8-bit registers.
16-bit 4 Emulated as two 16-bit registers.
32-bit 4 Doesn't have to be emulated.
64-bit 4 or 8? Doesn't have to be emulated.
Now I have doubts only on 64-bit machines, where 'long int'
may be that 'at least 32 bits', but it can be more also
So if it can, sould it or not?
Next, we have 'short int', which the Standard requires to be
at least 16 bits. So, let's look:
Machine word: sizeof(short int):
8-bit 2 Emulated as two 8-bit registers
16-bit 2 Doesn't have to be emulated.
32-bit 2 Doesn't have to be emulated.
64-bit 2 Doesn't have to be emulated.
Here, I have some doubts on 64-bit platform. On 32-bit
'short' is mostly 16-bit and no more, because it should be
able to be shorter than plain 'int'. On 64-bit platforms
it could be more, if plain 'int' were 64-bit. But I don't
know how it is there, and I've seen only one particular
case, where plain 'int' has still 32 bits, so the 'short
int' has to be 16-bit.
And now we come to plain 'int' type
The Standard requires it to be at least as much as 'short int',
and defines it as the type most convenient for integer arithmetics
on the particular platform. So, if we apply the same rules as
for 'long int' [with the emulation], we would get:
Machine word: sizeof(int):
8-bit 2?? Emulated as two 8-bit registers??
16-bit 2 Doesn't have to be emulated.
32-bit 4 Doesn't have to be emulated.
64-bit 4 or 8? Doesn't have to be emulated.
I don't think emulating 'int' as two 8-bit registers to be
the most convenient for the 8-bit platform to compute on
integers
Even if 16-bit platforms could emulate C++
Standard rules and feel good with it, for 8-bit machines
there is something wrong, I think. Something, that was
missed by the creators of Standard, or [more probably
]
by me :/ So what is the thing I am missing here?
I think I know the theory [C++ Standard] but I don't know
how to apply it in practice.