#135242 - Ant6n - Sat Jul 21, 2007 9:22 am
Hi,
is it a bad idea to use the 8bit bus sram as normal memory on gba?
I am running out of memory (the 16+256KB), and i really need byte writes and reads. Also it seems sram can be overclocked to run at 2 waitstates, which should make it faster than external ram.
#135243 - Dwedit - Sat Jul 21, 2007 9:33 am
I'd say use up your VRAM before you start digging into SRAM.
If you are writing your code for a flash cartridge, know that some flash software does not bankswitch the second 32k of SRAM properly, making high SRAM writes step on other toes.
If you are making a multiboot program with your code in EWRAM, you can even place your code into VRAM instead, and it will run faster, but then you are forced to use long jumps if you want to call code in a different memory area.
In the meantime, here is some asm code to do an 8-bit write to 16-bit memory (taken from the 'read modify write' thread):
Cearn wrote: |
Here's one for 7 instructions, without masking.
Code: | @ void byte_write(void *ptr, u8 value)
byte_write:
eor r2, r0, #1
ldrb r3, [r2] @ Read the *other* byte
ands r2, r0, #1 @ Test and prep for alignment
orreq r3, r1, r3, lsl #8 @ Even: src-byte needs shift
orrne r3, r3, r1, lsl #8 @ Odd: value needs shift
strh r3, [r0,-r2] @ Align and write
bx lr
|
|
I'd suggest against overclocking the SRAM, as overclocking is too unpredictable as to whether it will work or not.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#135296 - Ant6n - Sat Jul 21, 2007 11:49 pm
Well, I think i am pretty much out of iwram,vram,ewram; and my 8bit writes shouldn't trash the flags.
So you say 32k of sram is safe to use; 64k is probably safe to use usually (and checking whether its overlapping is probably easy). even without overclocking i still get 'only' 5 waitstates.
I was just more concerned that reading/writing a lot to the sram, like 300K/s. I.e. whether it wears the ram out or something.
#135320 - Miked0801 - Sun Jul 22, 2007 6:58 am
If you are also saving info in the sram anywhere, then sram is not safe to use as normal RAM. When you turn off the GBA, random writes to memory occur and these can (and do) wipe out random parts of SRAM if you are allowing access. I got burned by this in GBC land :)
#135403 - Ant6n - Mon Jul 23, 2007 4:06 am
i dont understand. wouldnt normal ram be wiped out anyway?
btw, i think i might have figured out a way to do 8bit writes (only) to flash ram; simply by multiplying every address by two. I think I read somewhere 8bit writes get doubled...
#135466 - Miked0801 - Mon Jul 23, 2007 6:54 pm
Yes, normal RAM would. But if you are using SRAM for save data (which is what it is traditionally used for) then it will be wiped randomly as well.