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 > Illegal reads/writes

#74086 - sgeos - Thu Mar 02, 2006 6:42 am

The following kinds of errors are showing up in VBA's log:
Code:
Illegal halfword write: ff24 to 0935e564 from 08022f64
Illegal word read: 0000001c at 08078482
Unaligned word read: 0201908e at 0805a60e

I'm assuming that illegal reads and writes have no effect. What is the net result of an unaligned read or write?

EDIT: I'm specifically interested in the side effects of unaligned reads and writes.

-Brendan

#74087 - gladius - Thu Mar 02, 2006 7:25 am

Un-aligned read/writes actually read/write to the address % size. So if you write a word to 3, it will actually write a word to address 0. Read also shifts the addressed byte into the high byte of the word I believe.

I actually asked this same question a while back :).

http://forum.gbadev.org/viewtopic.php?t=3330&highlight=unaligned+read.

#74094 - sgeos - Thu Mar 02, 2006 10:04 am

Thanks.

-Brendan

#74116 - tepples - Thu Mar 02, 2006 4:22 pm

sgeos wrote:
The following kinds of errors are showing up in VBA's log:
Code:
Illegal halfword write: ff24 to 0935e564 from 08022f64
Illegal word read: 0000001c at 08078482
[...]

I'm assuming that illegal reads and writes have no effect.

Not always. Illegal writes to GBA ROM space (0x08000000 through 0x0DFFFFFF) may end up writing to savegame space if you're using EEPROM save, or it may end up crashing the flash card if you're on some brands of flash card (such as Nintendo's) that don't have stray write protection. In any case, try to eliminate illegal writes if you want your program to pass lot check (either Nintendo's or NO$GBA's).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.