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 happens when I use 'new'?

#93688 - Lick - Thu Jul 20, 2006 6:45 pm

Where does the memory come from? NOT from the hardware I suppose..?
_________________
http://licklick.wordpress.com

#93717 - racarate - Thu Jul 20, 2006 9:40 pm

All memory comes from hardware. Where else would it come from?
_________________
Neko: I love meow-tain climbing!
Need anything? I'll even save your game!

#93723 - Lick - Thu Jul 20, 2006 10:05 pm

Perhaps ROM? The linker allocates the memory in static ROM-space.. just like the not-newed memory..

But yeah, I guess so. Really hits me when the DS has 4MB RAM but just a few KB VRAM?
_________________
http://licklick.wordpress.com

#93744 - tepples - Thu Jul 20, 2006 11:15 pm

The operator new normally allocates from the heap. Many implementations of operator new use malloc() of <cstdlib> as a back end. In devkitARM, malloc() is supposed to use a heap in EWRAM, but this is broken on the GBA in devkitARM R19.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#93855 - poslundc - Fri Jul 21, 2006 5:59 pm

Lick wrote:
Perhaps ROM? The linker allocates the memory in static ROM-space.. just like the not-newed memory.


I'm sure you realize ROM stands for Read Only Memory... you cannot dynamically allocate memory in ROM - not usefully, anyway - because you cannot write to it.

Dan.

#93914 - Lick - Fri Jul 21, 2006 11:51 pm

Ow.. I just meant from the cartridge then. But I guess it's in the hardware after all.
_________________
http://licklick.wordpress.com

#93947 - tepples - Sat Jul 22, 2006 2:04 am

poslundc wrote:
I'm sure you realize ROM stands for Read Only Memory... you cannot dynamically allocate memory in ROM - not usefully, anyway - because you cannot write to it.

"Cart ROM" also stands for an address space in the Game Boy Advance and Nintendo DS. This may be writable, especially if you have a SuperCard inserted, but the known linker scripts don't support this because GCC can't be made to use read-modify-write for 8-bit writes to ROM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.