user1773603
user1773603

Reputation:

Memory access on 32 vs 64 bits architectures

by default, what's the standard size of a variable that can be read on 32 bits and 64 bits processor using a single instruction?

For example, when I have a double (8 bytes size) in C language is it read respectively in one instruction (on a 64 bits processor) and in two operations (on a 32 bits processor) ?

I think this problem is actually the difference between what we call the "memory word" (which is equal to 1 byte) and the "processor word" (I don't know this size value but it would depend of 32 bits or 64 bits processor, right ?).

Thanks

Upvotes: 3

Views: 1556

Answers (3)

igon
igon

Reputation: 3046

It depends on the ISA of the processor which is somewhat unrelated to the size of a virtual memory address or integer size ( 32 vs 64 bit ).

As an example consider vector extension instruction that are available on many processors, they operate on chunks of memory which are bigger than the processor word: http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions http://www.arm.com/products/processors/technologies/neon.php

It is true that when referring to 32bit or 64 bit processor, without further specifications, we intend that all the processor datapaths (including address and integers) have the corresponding size.

In practice, many processors (including x86/ARM)

  • Use different sizes for integer/floating point datapaths and addresses, e.g. Pentium processors had 32 bits integer but a 64 bits data bus Pentium Manual.
  • Provide single instructions in their ISA that operate on multiples (or fractions) of the standard processor word, e.g. ARM processors can load a double word (64 bit) from memory even if the processor is 32 bit.

This is done to have a better performing processor; if an instruction is provided to load a double word then only one instruction has to be fetched, decoded, issued, executed and committed instead of two. Similarly vector instructions can perform a job that would require many instructions using a single one, greatly reducing the load in the pipeline of a processor.

Upvotes: 1

Keith Thompson
Keith Thompson

Reputation: 263577

There is no consistent and universal definition of what the terms "32-bit" and "64-bit" actually mean. There are perhaps half a dozen or so characteristics that could be used to define them (data bus width, address size, general-purpose CPU register size, probably others).

The terms are most meaningful within an architecture family. For example, it makes sense to compare the characteristics of the x86 and x86_64 architectures, or the 32-bit and 64-bit versions of SPARC.

Bottom line: Though your question is not necessarily vague, any possible answers to it probably are. A so-called "32-bit" CPU might very well have instructions to access 64-bit quantities. On the other hand, the Motorola 68008 implemented a 16/32 bit instruction set architecture, but only had an 8-bit external data bus; its 8-bitness was invisible to applications apart from a speed penalty.

Upvotes: 1

Eric J.
Eric J.

Reputation: 150158

32-bit processors work on 32 bits of data at a time. 64-bit processors work on 64 bits of data at a time.

is it read respectively in one instruction (on a 64 bits processor) and in two operations (on a 32 bits processor) ?

A "generic" 32-bit processor would have fetch two 32-bit chunks of data separately and combine them. The exact number of instructions may depend on the processor.

Having said that, many processors have specialized architectures to better handle floating-point data

http://en.wikipedia.org/wiki/Floating-point_unit

While most concrete 32-bit processors will need two fetch operations to load a 64-bit integer, the same may not be true for floating-point types on the same processor.

Additionally, some processors have the ability to process vectors in few instructions. Most modern C compilers are able to emit such instructions when appropriate. See for example:

http://en.wikipedia.org/wiki/SSE2

Upvotes: 1

Related Questions