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.

Beginners > Does the GBA execute from the cartridge or internal memory?

#21907 - Mr. GBA - Wed Jun 09, 2004 1:08 pm

Hi,

I'm a bit confused as to wheter instructions are directly executed from the cartridge or from some internal GBA memory chip.

I ask this because I always used to think that insructions were executed from the cartridge until one day when I decided to pull the game pak out and found the game was still running.

Also, do the memory areas (IWRAM, EWRAM, VRAM etc) refer to the game pak or gba internal memory chip locations?

Last question. If the game pak data is read into the GBA and then executed, where is the default read image in the game pak?

Any reply would be appreciated. Thanks very much.
_________________
my dev/business site:

http://codebytesdev.afraid.org

#21908 - ampz - Wed Jun 09, 2004 1:21 pm

Mr. GBA wrote:
Hi,

I'm a bit confused as to wheter instructions are directly executed from the cartridge or from some internal GBA memory chip.

I ask this because I always used to think that insructions were executed from the cartridge until one day when I decided to pull the game pak out and found the game was still running.

Also, do the memory areas (IWRAM, EWRAM, VRAM etc) refer to the game pak or gba internal memory chip locations?

Last question. If the game pak data is read into the GBA and then executed, where is the default read image in the game pak?

Any reply would be appreciated. Thanks very much.

I feel this kind of post belongs to the beginners section..
Code can be executed directly from the cart, or from internal RAM. It's up to the programmer. IWRAM, EWRAM and VRAM are internal to the GBA.

#21909 - Mr. GBA - Wed Jun 09, 2004 1:29 pm

Ok..thanks for the reply.

But if the ROM cartridge data is loaded into 0x08000000.

Where is the offeset that data is being loaded from in the cartridge?
_________________
my dev/business site:

http://codebytesdev.afraid.org

#21910 - poslundc - Wed Jun 09, 2004 1:49 pm

Mr. GBA wrote:
But if the ROM cartridge data is loaded into 0x08000000.

Where is the offeset that data is being loaded from in the cartridge?


If it's from the cartridge, then it's from the ROM.* That means 0x08000000.*

Some other sections for ya:

VRAM - 0x06000000
Palette RAM - 0x05000000
OBJ RAM - 0x07000000
EWRAM - 0x02000000
IWRAM - 0x03000000
BIOS - 0x04000000

http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm

Dan.

*- SRAM and alternate ROM banks not withstanding.

#21957 - MumblyJoe - Thu Jun 10, 2004 1:43 am

Just gotta say, Ampz - was it really necessary to quote the entire post before replying to it? :P
_________________
www.hungrydeveloper.com
Version 2.0 now up - guaranteed at least 100% more pleasing!

#22014 - DekuTree64 - Fri Jun 11, 2004 7:29 am

When a game starts up, it's in ARM mode and executes the instruction at 0x8000000, which is the first part of the ROM. Since the area immediately after that first 4 byte instruction is where the header for the game is stored, that instruction is always a branch, which is made to wherever your startup function is (usually _start or start_vector or something right after the header in Crt0.S), which then goes and sets up the stack pointer copies code to RAM if you tell it to, and then branches to AgbMain() (or wherever else you tell it to in Crt0.S). Actually even that startup code is free to skip and do whatever you want with. Only the first branch HAS to be done, to get past the header. Unless of course if you can figure some way of making a valid header out of working ARM code^_^ Really, it's simple once you understand what's happening.
Still, it seems strange that a game could keep running after having the cart pulled. EWRAM does take less battery power to read from than ROM, so it's good to store your non-speed-critical, but often called code in there, but usually at least the instrument samples for music are always read from ROM, since they're so big. Did you happen to have the volume up when trying that? Maybe it doesn't lock up if it tries to read from ROM with no cart, but just gets back zeroes or garbage. I might just have to test that sometime.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku