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 > Reverse-engineering BIOS functions

#14839 - animension - Tue Jan 13, 2004 4:16 am

How would one figure out what, exactly, a BIOS function does in assembly? Is there a lookup table that the interrupt uses to reference a particular location in BIOS to process and execute each SWI, and if so where is it?
_________________
"Beer is proof that God loves us and wants us to be happy."
-- Benjamin Franklin

#14855 - tepples - Tue Jan 13, 2004 3:05 pm

Yes, there exists such a lookup table. No, I don't have a copy of the disassembled BIOS handy to look it up.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#14857 - Miked0801 - Tue Jan 13, 2004 6:15 pm

Martin Korth came up with a method for finding out what was in the BIOS using a bug in one of the midi commands to read from the restricted area. I'm not sure of the specifics though. Basically, you set it up in a loop and have it dump the memory somewhere where you can read it. BTW, you won't be impressed with what you see if you do get to look at it ;)

Mike

#14861 - animension - Tue Jan 13, 2004 7:07 pm

I'm just glad that there is a LUT that I can use to reference SWI instead of having to reverse engineer the entire BIOS. That would suck. :)
_________________
"Beer is proof that God loves us and wants us to be happy."
-- Benjamin Franklin

#14883 - sasq - Wed Jan 14, 2004 10:02 am

The SWI-routine is at $140, and it uses the byte in the SWI-opcode to look up an adress in a table at $1C8

An interesting thing is that it doesnt check if the byte is outside the table, so you can find a few SWI-numbers that jumps to ROM or RAM, which means you could use SWI to jump to your own code if you needed to (maybe for breakpoints).

#14926 - tepples - Wed Jan 14, 2004 8:33 pm

sasq wrote:
you can find a few SWI-numbers that jumps to ROM or RAM, which means you could use SWI to jump to your own code if you needed to (maybe for breakpoints).

Perhaps, but don't use SWIs to RAM in production code. Nintendo reserves the right to change the layout of the BIOS and add more functions in future Game Boy platforms.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.