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.

ASM > ARM7 core

#85887 - sephiroth111 - Fri Jun 02, 2006 9:29 pm

I want to make an ARM7 CPU core emulator in ARM9 assembly for the gp2x. It seems like a daunting task, and virtually impossible to one such limited knowledge as I. I know that most of the ARM7TDMI's instructions are compatable with the arm9.

Since most of the people here have an idea of what this task consists of, i ask what would i need (in instruction wise), and what should i know about.

#85897 - tepples - Fri Jun 02, 2006 10:57 pm

You're trying to make a GBA emulator for a GamePark or GamePark Holdings handheld system, aren't you? Or is it on Pocket PC?

First you'll need to make one to throw away. Your first emulator will have an interpretive core, meaning that it will fetch, decode, and execute each instruction and will run 10 to 20 times slower than native code. Only once you fully understand the interpretive core can you develop a virtualizer, which translates ARM code that writes to GBA registers into ARM code that writes to GP32/GP2X registers or ARM code that calls DirectX while keeping inner loops (e.g. audio mixers, physics, and NPC intelligence) native.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#85921 - sephiroth111 - Sat Jun 03, 2006 4:59 am

tepples wrote:
You're trying to make a GBA emulator for a GamePark or GamePark Holdings handheld system, aren't you? Or is it on Pocket PC?

First you'll need to make one to throw away. Your first emulator will have an interpretive core, meaning that it will fetch, decode, and execute each instruction and will run 10 to 20 times slower than native code. Only once you fully understand the interpretive core can you develop a virtualizer, which translates ARM code that writes to GBA registers into ARM code that writes to GP32/GP2X registers or ARM code that calls DirectX while keeping inner loops (e.g. audio mixers, physics, and NPC intelligence) native.


GP2x unit, good guess. i'm looking at the VBA sources as well as the GPadvance sources, and its way too complicated looking =).

obviously rome wasn't built in a day, so i'll keep it up, but knowing absolutly nothing about the arm7/9 asm as well as even how to write an emulator in general doesn't really help (i pretty much want to take the modified GP2x VBA sources, and dump the CPU into that, instead of rewriting the entire codebase. it functions well enough that i can just remove the core chunks and recode them one at a time... i guess.

#86020 - tepples - Sat Jun 03, 2006 11:14 pm

First make a Game Boy (classic) emulator as practice. It's a much simpler system, and most of the skills will transfer.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#86048 - gladius - Sun Jun 04, 2006 2:00 am

There are tons of cool tricks you can do when emulating a processor on the same processor type. If there is a MMU on the GP2X then you can have even more fun trapping memory accesses and redirecting to your I/O handlers or whatever.

Of course if you just jump into the code the processor will happily never come back to you. Counting CPU cycles is also very tough using this method, but it's certainly doable, you can treat it like a dynarec where you execute a cpu chunk until a branch and then the dynarec generated code is just arm code.

Lots of fun possibilities :).

Edit: I agree with Tepples though, a simpler project to start might be more prudent.

#86066 - Dwedit - Sun Jun 04, 2006 4:33 am

gladius wrote:
Of course if you just jump into the code the processor will happily never come back to you.


That's what Interrupts are for!
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#86112 - tepples - Sun Jun 04, 2006 3:02 pm

Dwedit wrote:
gladius wrote:
Of course if you just jump into the code the processor will happily never come back to you.

That's what Interrupts are for!

Unless the emulated program overwrites the interrupt registers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#86139 - gladius - Sun Jun 04, 2006 7:13 pm

Dwedit, of course, interrupts will work, but at that point your cycle counting is going to be wildly inaccurate, and the GBA still relies on at least semi-accurate cycle counts.

Tepples, good point, if the program turned of interrupts on the CPU then you would be in some pain :).

IMO, a dynarec is the best tradeoff between speed and accuracy.