News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

Post your GBA ASM Questions here.

Started by Daddy Poi's Oily Gorillas, 03, November, 2010, 06:10:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Daddy Poi's Oily Gorillas

#40
QuoteNo no, it has nothing to do with the SNES.
With pins, I mean the wires coming out of the cpu.
A CPU needs some of them to let the data bus arrive at the right place.
Yeah, a little later (esp. seeing that "pins" is on GBATEK), I started to question myself about that...

I'm not sure how the internals work yet...

Mainly just the assembly stuff (Including I/O, since assembly uses it.) was as far as I went... (And I'm sure it's possible I could still come across something I didn't know... Don't we all?)

QuoteOh okay, that cleared another thing up. I really fought the flags were in some registers.
I think it is like this:
-Thumb mode sets them automatically, and only the branch instructions are conditional.
-ARM mode gives you a choice whether to set conditional flags (per instruction), and a choice if any instruction should be conditional.

QuoteWell, you literally anwsered it here. 28bits it is.
Not sure exactly how useful knowing that is... since you'll most likely be accessing them via 32-bit addresses/pointers. (Where the first hex digit is 0.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

Quote from: Fox on 19, October, 2016, 03:50:51 PM
I'm not sure how the internals work yet...
Which internals? Of CPU's in general or more like the internals of a GBA?

Quote from: FoxI think it is like this:
-Thumb mode sets them automatically, and only the branch instructions are conditional.
-ARM mode gives you a choice whether to set conditional flags (per instruction), and a choice if any instruction should be conditional.
That seems pretty nice to have.
And yeah the thing that instruction could require conditions, it's a bit weird after years of only non-assembly languages, but actually seems like the thing I will use a lot.

Quote from: FoxNot sure exactly how useful knowing that is... since you'll most likely be accessing them via 32-bit addresses/pointers. (Where the first hex digit is 0.)
I think I overlooked the uselessness as well.
After a short calculation, 28bits should be enough for 200MB... AFAIK, biggest normal GBA ROMs are 32Mb and assuming internal memory address take up only 1Mb...
2^25 would fit the bill perfect.
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Daddy Poi's Oily Gorillas

#42
Both. I mean, I might know some basics here and there, but I wouldn't call myself an electrical guy /yet/....
(e.g. I know what a CPU, fan, heat sink is... where to locate them... etc... I've also remember learning something on voltage/amps/ohms once... but can't say that I'm well-versed in it, though.)

QuoteThat seems pretty nice to have.
The S flag...

QuoteAnd yeah the thing that instruction could require conditions, it's a bit weird after years of only non-assembly languages, but actually seems like the thing I will use a lot.
More than Branch Conditionals? You could go either way...

QuoteI think I overlooked the uselessness as well.
After a short calculation, 28bits should be enough for 200MB... AFAIK, biggest normal GBA ROMs are 32Mb and assuming internal memory address take up only 1Mb...
2^25 would fit the bill perfect.
I mean, if you want to know everything that is on the memory map, it isn't really that much:

Quote from: GBATEKGeneral Internal Memory

  00000000-00003FFF   BIOS - System ROM         (16 KBytes)
  00004000-01FFFFFF   Not used
  02000000-0203FFFF   WRAM - On-board Work RAM  (256 KBytes) 2 Wait
  02040000-02FFFFFF   Not used
  03000000-03007FFF   WRAM - On-chip Work RAM   (32 KBytes)
  03008000-03FFFFFF   Not used
  04000000-040003FE   I/O Registers
  04000400-04FFFFFF   Not used

Internal Display Memory

  05000000-050003FF   BG/OBJ Palette RAM        (1 Kbyte)
  05000400-05FFFFFF   Not used
  06000000-06017FFF   VRAM - Video RAM          (96 KBytes)
  06018000-06FFFFFF   Not used
  07000000-070003FF   OAM - OBJ Attributes      (1 Kbyte)
  07000400-07FFFFFF   Not used

External Memory (Game Pak)

  08000000-09FFFFFF   Game Pak ROM/FlashROM (max 32MB) - Wait State 0
  0A000000-0BFFFFFF   Game Pak ROM/FlashROM (max 32MB) - Wait State 1
  0C000000-0DFFFFFF   Game Pak ROM/FlashROM (max 32MB) - Wait State 2
  0E000000-0E00FFFF   Game Pak SRAM    (max 64 KBytes) - 8bit Bus width
  0E010000-0FFFFFFF   Not used

Unused Memory Area

  10000000-FFFFFFFF   Not used (upper 4bits of address bus unused)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

Quote from: Fox on 19, October, 2016, 11:03:14 AM
@1 = Can't say, but there's a list here, at this old website. http://www.gbadev.org/tools.php?section=Build (devkitadv is pretty old, so if that was looked at, then you can also consider devkitpro... assuming you can get it to work.)
Well guess what? This popped up another Question.
What do you use to write ASM?
Which brings me to: GBA ROM's need always have the same starting pattern right?
How do I put that in the ROM?

I've tried getting the devkits to work (nope).
There is FASM... which is not very beginner friendly I think.
And HAM also doesn't work?
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Daddy Poi's Oily Gorillas

#44
QuoteWhat do you use to write ASM?
Any text viewer like Notepad. (Or any IDE you want.)
QuoteWhich brings me to: GBA ROM's need always have the same starting pattern right?
How do I put that in the ROM?
Yeah... Mainly setting stack addresses and such.. (I think devkitadv automatically inserts the needed stuff plus more if coding from C/C++??? (Not the Nintendo header, though. It's 0'd.) But I'd need to look into how that works a bit more.)
QuoteI've tried getting the devkits to work (nope).
Did you try downloading one of the tutorials? (If using devkitadv.)
I know that it features C/C++... But I think you can probably still do ASM files as well. (Haven't tried yet.) If not, you can /still/ write out some asm in C/C++ if you use a certain command.

@C/C++ = I remember trying devkitpro before... Had problems... But I did eventually manage to get something working through one of the NDS examples... (After trying to fix Environmental Variables/opening Programmer's Notepad as admin.) HOWEVER, there was a point that when I tried again... problems come up (If I remember correctly.)... I'm guessing something to do with permissions somehow... And opening as admin didn't seem to help much like it did the first time... I'm a bit confused, so I kind of temporarily went back to devkitadv.


---
Didn't try FASM...
Definitely didn't try HAM... and wasn't planning to since I read it was closed source. - Could probably give it a try for lulz some day, though.
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

QuoteAny text viewer like Notepad. (Or any IDE you want.)
Haha, Notepad as IDE (I know it's a thing though).
Anyway, after writing it you just assemble it with some program I assume?

Maybe i'm confusing GBC with GBA, but wasn't some kind of nintendo logo (inside the ROM) necesary for boot up?

I have to look into devitadv maybe.
I'm not so interested in C/C++. Not for GBA at least.
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Daddy Poi's Oily Gorillas

#46
QuoteAnyway, after writing it you just assemble it with some program I assume?
The concept the devkitadv uses, is to run a batch file.  devkitpro does Make files, though... (In that case, you use the Make function in Programmer's Notepad.)
Let me know if you are actually able to do the .asm files properly... (Still need to look into it myself on whether it is straight-forward.... or even possible... but my guess is that it's possible.)


QuoteMaybe i'm confusing GBC with GBA, but wasn't some kind of nintendo logo (inside the ROM) necesary for boot up?
I'm always editing my posts right after posting... But that is true on an actual GBA. (May not be necessary on an emulator, however.)

QuoteI have to look into devitadv maybe.
I'm not so interested in C/C++. Not for GBA at least.
Okay... devkitadv is likely outdated, so have fun!
And I like it best when you can do both C/C++ and assembly... Although, I 'd really like to look into how the compilers optimize their stuff... I do know that assembly takes longer to code in (when you are fluent in the necessary stuff), either way, if that helps decision making, so...




If it turns out things are versatile enough... I might even consider converting a lot of GS2 code into assembly for my project, but I'd want it to be different from the assembly you see in the game... By that, I want things like variables names, etc... (A bunch of stuff to think about.)

I'm actually contemplating on creating my own compiler... with the thought that the code could potentially stay 1:1... Maybe.. That'd probably be a challenge though, but who knows what's best... Rich asm to compatible-asm.... Hard to say... I figure C/C++ would have the most universal platform-compatibility, though. (If you code it clean...)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

C is 1:1 you just have to know how it translates.
I think the real difference with assembly is less writing and not having to make your own memory map.

It would be really handy to have an IDE with a memory map, with an option to give blocks a different colour (to distinguish code and values).
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Daddy Poi's Oily Gorillas

#48
When I say 1:1, I actually just mean being able to duplicate GS2's code in C/C++/other and have it compile to how it appears in the ROM. (Rather than something different that does the same exact thing.)

@Assembly: While I may know the compiled assembly... I'm not 100% sure about how it should be coded in practice. (The one where people have labels like .arm and .thumb... and such... there could be quite a number of things I'm missing... and I'm not even sure if it even has anything like C/C++ defines. (asm style.)) I know that doing it the (not recommended way) will just get so much in the way that it isn't worth bothering anymore, though...
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

#49
[spoiler]Basically I got devkitARM installed.
Now I don't know yet how to work with this and if I follow the steps of a tutorial, errors come up (which I cannot find anywhere on the internet).
I think I know how it works for so far:
-you write code in a file or files.
-makefile file is used to call devkitARM's right compiler/assemblers
-in the assembling step, devkitARM fixes the GBA header if it is wrong.
-a GBA file is made.

Now the thing is, aside from that I can't get it to work, I understand that devkitARM does a lot of stuff for you.
By that I mean placing your code somehow in the EWRAM and having stuff in the header.
This is not what I want. I would just like to have my own code right after the header (where the GBA starts).[/spoiler]
Mhh... text above was written when I was very tired.

I basically got devkitARM working.
My steps:
-copy template
-Make .S file and put it in the Source folder
-cmd [current directory]>make
-a .gba rolls out.

I will check the thing I said yesterday, whether devkitARM has it's own way of deciding were your code is placed or that it always uses the first address after the header.
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Luna_blade

bumping

Is there a way to (in any emulator) to watch memory and the current instruction and when you press a next button, the view updates?
I'm sorry for the weird wording, but I don't really know how to explain otherwise.
I basically want something like breakpoints (and maybe for every line).
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Lord Wolfram

GBA ASM to C conversion?
Possible thing?

Luna_blade

It's sort of possible.
The inverse can be done in devkitARM, but I don't know how.

A big downside is also that if you do ASM -> C then change some things and then C-> ASM, it will be pretty different.
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Daddy Poi's Oily Gorillas

#53
QuoteGBA ASM to C conversion?
Possible thing?
Could be... For basic "ugly" C, anyway... The more complete user-friendly structuring could increase the time/difficulty, though....

QuoteA big downside is also that if you do ASM -> C then change some things and then C-> ASM, it will be pretty different.
Or just simply ASM -> C then C -> ASM without changing anything... (Assuming the compiler compiles differently than the originally ASM...) Hard to say if it is an actually downside without comparing to see if it optimized it further or less... (But that's only assuming the optimizations are more important than asm editing.)


EDIT AGAIN:

Quotebumping

Is there a way to (in any emulator) to watch memory and the current instruction and when you press a next button, the view updates?
I'm sorry for the weird wording, but I don't really know how to explain otherwise.
I basically want something like breakpoints (and maybe for every line).
So something like no$gba debugger or VBA-SDL-H?
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

I still haven't got the devkitARM assembler working (I can't build .S or .asm files)...

But now I know enough about devkitARM and all that, I really think I prefer just writing the code in assembly and then putting it in the ROM myself.
So is there any tool that lets me convert assembly to hex or binary?
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Salanewt

The way I do it is to manually enter stuff in by hand (using the THUMB chart in the downloads section as a mostly accurate reference guide), but that can take forever.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Luna_blade

#56
No easy assembler tool?

Heh. I might make my own if I feel like it.

That THUMB chart will be pretty usefull. Thanks!  :happy:
BX RXBranch and exchangeBranches to the specified RX containing an ARM or THUMB instruction, and optionally executes it. To select an ARM instruction the BX instruction needs to be at a word-aligned address. To select a Thumb instruction specify register R15 as RX.
with "branches to RX" I suppose that means branches to the address stored in RX?
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"

Salanewt

#57
I'm sure there are some floating around but I never bothered learning where to find one and how to use it effectively.

That's exactly it, yeah. I use those a lot and they tend to look like this:

08000000: LDR r4 [x08000004]
08000002: BX r4
08000004: [ADDRESS]


More or less anyway.

Also, I'm happy to help! One thing to keep in mind is that Fox and I both think that a couple of the instructions may be switched around, but I also based the chart off of what the VBA disassembler displayed for instructions so the same issue would be in that tool too. I think it was one of the various load bytes with a load or store short (or something).
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Daddy Poi's Oily Gorillas

#58
Address in register jump, yes.
Its main use is for long jumps, I believe, since bl is limited to a certain range.... (Think calling a function in RAM from ROM... etc.)


so bl to whatever has the bx instruction, basically... (bx doesn't save return address like bl, so you'd still need bl in that case.)


It also works for returns as well. (But entirely optional if you do it with push {lr} pop {pc} set.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Luna_blade

I have a question about the ARM B(ranch) opcode.
How exactly do I known the destination address?
Is it simply r15 - Boffset ?
From what I've tested in VBA, it isn't simply doing that (but I may be wrong) and I'm too lazy to test every possibilty.
"Hear the sounds and melodies
Of rilets flowing down
They're the verlasting songs
Whispering all the time
As a warning that behind some rocks
There's a rigid grap even
Oreads fear the tread"