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 > GBA machine code

#168004 - bollkalle - Mon Apr 06, 2009 5:13 pm

How do I program in machine code to GBA? I think that GBA has an own set of machine code instructions. If someone knew, I would like to know how to do this.

/bollkalle

PS. And don't say anything about assembly. I want to program in machine code, not one step higher.

#168005 - DiscoStew - Mon Apr 06, 2009 5:53 pm

Are you asking if it has it's own set of unique machine code instructions? If so, then I would say no. The GBA does not. It's based on the ARM7TDMI family (ARMv4T architecture, ARM7TDMI(-S) core), and many other devices use that type of CPU.


While I know you don't want to hear this, but assembly IS the closest thing you're gonna get to machine code outside of coding machine code directly because, afaik, it translates directly to it when compiled (unlike from high-level code to assembly). Each line of code in assembly is basically a single instruction. Besides, you not only get the benefit of direct conversion, but also far more readable code and debugging features (because, who wants to be writing code in 0s and 1s anymore?).

Trust me, go with assembly, because it is machine code, but formatted a whole lot better for the programmer to understand.
_________________
DS - It's all about DiscoStew

#168006 - elyk1212 - Mon Apr 06, 2009 6:38 pm

Yeah, the only reason I've ever seen instructions coded in binary files was when we didn't have a compiler (proprietary hardware design) and were only checking basics of the new processor functionalities.

As design and testing progresses someone makes an assembler, then finally a C compiler/ etc.

Binary files for loading anything but the most basic (atomic) functionalities = banging head against monitor.

#168007 - Dwedit - Mon Apr 06, 2009 7:00 pm

Or it could mean "I have no I/O and need to type in HEX to run ASM code".
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#168008 - elyk1212 - Mon Apr 06, 2009 8:15 pm

By "no I/O", do you mean no peripheral I/O on the test board? Yikes, without some type of hooks or handles, I would hate to test that setup ;). What do you mean by "type in HEX to run ASM"? Creating bootstrap code? AFAIK, you can still do this with an assembler and just write it to ROM.

In my limited experience, many times it was one or the other... with no assembler one had to enter instructions by hand, without any choice. After loading the instructions in to ROM, we'd test by checking pins the program was to flip with a logic analyzer based on the test... yeah that was our only "live" output to the user (and we were only testing basic ops (but on a 40 core processor :Z, what a mess that was)).

But we still had a way to load instructions to ROM, whether or not these instructions were first created by an assembler should have been indeterminable (should one have existed).

#168009 - Dwedit - Mon Apr 06, 2009 8:20 pm

I mean typing in ASM code into a TI83 with a broken link port. It works, but it really sucks.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#168010 - elyk1212 - Mon Apr 06, 2009 8:22 pm

Ouch, that does sound painful. So you were one of those guys in classes with all the crafty solvers for diff eq and such. :P

#168012 - Dwedit - Mon Apr 06, 2009 8:40 pm

Nah, I was the guy who was porting Bubble Bobble. (check my website)
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#168013 - elyk1212 - Mon Apr 06, 2009 8:50 pm

Nice, my wife loves that game. Wonder if it will work on 81/82? Did you have to recreate all those graphics by hand? I would assume that going from color -> mono(with no tones) would be tough.

#168014 - DekuTree64 - Mon Apr 06, 2009 9:10 pm

Grab the "ARM7TDMI Data Sheet" from the gbadev.org documentation section. That shows all the instruction binary formats. Beyond that, all you really need to know is that your ROM will be at address 0x08000000 on the GBA and start executing from the first word in ARM mode. The GBA BIOS requires you to put a header at the start of the ROM, so the first instruction should be a branch past the header. Check GBATek for details.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#168015 - Dwedit - Mon Apr 06, 2009 9:29 pm

elyk1212 wrote:
Nice, my wife loves that game. Wonder if it will work on 81/82? Did you have to recreate all those graphics by hand? I would assume that going from color -> mono(with no tones) would be tough.


The TI81 has no link port (and thus no way to run user ASM code), but the TI82 version works great.
Redoing the graphics was fun. I used the old romhacking tool "Tile Layer" to draw the graphics, then some custom software to turn them into a series of .db statements for the assembler.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."