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.

ASM > Data access granularity?

#81257 - racarate - Fri Apr 28, 2006 12:23 am

Hi, I am just starting to learn ARM7.

Is it possible to acess only one byte?
_________________
Neko: I love meow-tain climbing!
Need anything? I'll even save your game!

#81261 - DekuTree64 - Fri Apr 28, 2006 12:38 am

Yes, you can read bytes, halfwords (2 bytes), and words (4 bytes). All registers are 32-bit though, so bytes and halfwords are zero or sign extended when loaded.

There is one catch though, that VRAM can't do byte access. You can actually read bytes because the CPU handles fetching only 8 bits from the bus, but if you try to write a byte to VRAM it will write 2 bytes instead.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#81262 - racarate - Fri Apr 28, 2006 12:40 am

Excellent, thanks!

I got sent this article at work and it had me wondering:

http://www-128.ibm.com/developerworks/library/pa-dalign/
_________________
Neko: I love meow-tain climbing!
Need anything? I'll even save your game!

#81267 - DekuTree64 - Fri Apr 28, 2006 1:05 am

Looks like that article is about some fancy new IBM chip.

One thing to note about ARM processors is that you can only read from an address aligned to the size you're reading. Like, halfword access must be on 2 byte boundaries. If you read from an odd address, the upper and lower bytes get swapped.

I have worked on a system before that ONLY had 2 byte access though. Quite fun actually, but ARM is much nicer :)
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#81332 - chishm - Fri Apr 28, 2006 1:22 pm

DekuTree64 wrote:
I have worked on a system before that ONLY had 2 byte access though. Quite fun actually, but ARM is much nicer :)

Would that not make it a 16-bit byte for that system, since 16 bits is the smallest data size it can work with?
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#81333 - Mighty Max - Fri Apr 28, 2006 1:40 pm

Thats not exactly clear chishm

It is true if he can only address 16bit aligned. But if it would be possible to read 16 bits from an only 8 bit aligned address, a byte would still be 8 bits.
_________________
GBAMP Multiboot