int vs char

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

Please let me know if this is not the right place to
ask this question.

I had read somewhere that a 32 bit processor can
read/write only and only 32 bits in any one cycle.

So, I thought that if I needed a 'char' then 32 bits
would be read from memory into registers and then
would be manipulated there to get a 'char'. As such I
thought that it was logical that operations on int are
faster than on chars.

I was reading an ARM processor manual some time ago
and I saw that processor has instructions to read a
single byte too.

So, I am confused now. I earlier thought that the
compiler generates such code that reads in 32 bits and
then manipulates those bits to get an 8-bit char
value.

Now, ARM processor manual says that the processor can
be instructed to read only one byte too. But the
processor registers are 32 bits. so, this is again
confusing.

This doesn't look very straightforward to me because
if the data bus is 32 bits wide then probably we are
still reading 32 bits.

So, the question is:

1. Can only 8 bits be read from memory in a 32 bit
register?

2. When a processor gives an instruction to read only
8 bits, then is it manipulating the 32 bits by itself?

3. If the address of my 'char' is 0x5, then do we only
read the memory location 0x5, or from 0x4 to 0x7, and
then manipulate it to get the value at 0x5 in the
lowest 8 bits of the 32 bit register.

Any help would be appreciated.

YKHAN


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux