gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > What do the numbers in pointers represent? (Size wise)

#146393 - NeX - Mon Dec 03, 2007 4:10 pm

I understand that each number addresses a space in the CPU's memory interface, but what do the numbers represent? Bits? Bytes? Words?
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#146394 - kusma - Mon Dec 03, 2007 4:20 pm

ARM CPUs (as well as practically all modern CPUs) are 8bit byte addressed. But be aware that the CPU can only read 16bit or 32bit variables directly if they are two or four byte aligned.

#147055 - elyk1212 - Thu Dec 13, 2007 9:21 pm

Quote:

CPU can only read 16bit or 32bit variables directly if they are two or four byte aligned


Yes. The bus is only so large, etc, therefore can only allow so many bits the line at one time.

But, as to not confuse the actual keyword 'aligned": Alignment, in that context, will attribute to how they are actually stored in physical devices (memory hierarchies, caches, RAM, etc).

So, not having alignment specified can lead to 'default alignment' choices on data, depending on the compiler.

Quote:

I understand that each number addresses a space in the CPU's memory interface, but what do the numbers represent? Bits? Bytes? Words?


I have to take care in what you are asking here, as I am not certain.

What do you mean by "the numbers"?

Are you asking what the numbers represent far as the actual address of a pointer ? 0x8223...blah blah. Yeah, these are byte addressable, so each atomic unit (um.. each additional number) represents one byte. The value contained in the pointer, as expected has the same properties (since it points to a memory address).

But, have fun if you are trying to address on an uneven boundary or other such pitfalls (I've done that more than few times on palm 68k ASM). Actually, it is fun just for educational purposes.


Hope that helps clarify (and hopefully I understood your question).

#147123 - qw3rky - Fri Dec 14, 2007 7:54 pm

@Nex

So in other words, yes, the numbers represent bytes.

There's no need to get wordy here guys. Address 0x0000 would be position 0 in bytes. Address 0x0010 would be position 16 (in hexadecimal) in bytes (so it would be 16 bytes into memory). And addresses are represented in hexadecimal to make certain pointer operations more convenient.

If you want to talk about the realities of actually accessing certain addresses and bits and bytes, then I think that's another question in itself.
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS