The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Emulation & ROM Hacking > Tutorials
Register New Account FAQ/Rules Chat Blogs Mark Forums Read

Notices

Tutorials Looking for a guide to help you out? Then you're in the right place! We've got everything you need, ranging from Mapping to Music!
New threads in this forum are to be approved by a moderator before they are displayed. The thread revival limit does not apply here.



Reply
Thread Tools
  #1  
Unread February 12th, 2011, 02:49 PM
knizz's Avatar
knizz
 
Join Date: Aug 2007
There is a compiler framework called LLVM. It's faster than GCC and opimizes code more aggresively and the llvm-frontend 'clang' has much better error-messages. I chose it to get rid of the devkit-dependency. (Which I didn't manage but ... at least I have fast code now.)

My clang version doesn't support arm (not because it can't but because the pre-compiled version doesn't include it.)
Fortunately the LLVM-Output is platform/cpu/os-independent. So I compile for x86 first and the override the cpu-type (i think clang ignores -march=thumb) when using llc.

http://llvm.org/docs/Passes.html lists all options for optimizations. They are supposed to be used with clang when it performs *all* actions. When you do linking, etc. yourself you probably have to give the optimization options to llvm-ld too.

Code:
clang -O4 -S -emit-llvm -march=thumb file1.c file2.cpp
llvm-as-2.8 file1.s
llvm-as-2.8 file2.s
llvm-ld-2.8 -o rom file1.s.bc file2.s.bc
llc-2.8 -O=3 -march=thumb -mcpu=arm7tdmi rom.bc
arm-thumb-elf-as -mthumb-interwork -o crt0.o crt0.S
arm-thumb-elf-as -mthumb-interwork -o rom.o rom.s
arm-thumb-elf-ld -q -Ttext=0x8000000 -Tbss=0x3000000 -o rom.elf crt0.o rom.o
arm-thumb-elf-strip -s rom.elf
arm-thumb-elf-objcopy -O binary rom.elf rom.gba
gbafix rom.gba
I use the crt0.S from http://velvetfr.ath.cx/gba/tutorial/gba-tutorial1.html
__________________
Firered IDA 6.1 DB Feb 8: https://www.dropbox.com/s/hvvmxxoo1dkmdzc/firered.idb
What I do: http://www.pokecommunity.com/search....&starteronly=1
VBA-M with lua scripting support / Dysfunctional Systems Episode 1 Opening
When you don’t create things, you become defined by your tastes rather than ability.

Last edited by knizz; February 13th, 2011 at 02:12 PM. Reason: Wrong instruction caused 210% bigger output. Fixed now.
Reply With Quote
  #2  
Unread February 12th, 2011, 10:13 PM
IIMarckus's Avatar
IIMarckus
J946@5488AA97464
 
Join Date: Oct 2007
Gender:
Quote:
Originally Posted by knizz View Post
Fortunately the LLVM-Output is platform/cpu/os-independent.
This is not correct. But it may (or may not) be close enough for your purposes; I don’t know enough about LLVM to comment.

I do like LLVM. It’s nice to finally see some competition to GCC, which is a bloated mess and a nightmare to build.
__________________
iimarck.us / hax.iimarck.us

If you want me, please contact me by email. [email protected]

If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

Pokémon Red disassembly project

Rules that should be rethought: 25charlimit, bumping.
Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
Good posts are good posts, regardless of how old the thread is—and brevity is underrated.
Reply With Quote
  #3  
Unread February 12th, 2011, 10:30 PM
knizz's Avatar
knizz
 
Join Date: Aug 2007
Quote:
Originally Posted by IIMarckus View Post
This is not correct. But it may (or may not) be close enough for your purposes; I don’t know enough about LLVM to comment.

I do like LLVM. It’s nice to finally see some competition to GCC, which is a bloated mess and a nightmare to build.
It simply means that the only platform-limitation is in your own code and not the compiler or llvm-representation. In other words: Your code will only work on the GBA when you write for GBA.

Platform-independent enough for my purposes.
__________________
Firered IDA 6.1 DB Feb 8: https://www.dropbox.com/s/hvvmxxoo1dkmdzc/firered.idb
What I do: http://www.pokecommunity.com/search....&starteronly=1
VBA-M with lua scripting support / Dysfunctional Systems Episode 1 Opening
When you don’t create things, you become defined by your tastes rather than ability.
Reply With Quote
  #4  
Unread March 2nd, 2011, 01:36 AM
Full Metal's Avatar
Full Metal
C(++) Developer.
 
Join Date: Jan 2008
Location: In my mind.
Age: 17
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to Full Metal
ohai how did I not see this thread?
nifty nifty, but does it have things like malloc and new built in (for C/C++ respectively)?
I mean, making my own malloc in asm would be as simple as using my FS code and making it into code that...works on a GBA, but you know, it's nice to avoid that. haha. I sound like I don't know what I'm talking about, but I do! ... yea! XD
__________________
Full Metal.‎"Fearlessness in those without power is maddening to those who have it."

Reply With Quote
  #5  
Unread March 5th, 2011, 02:32 AM
Silent Crest
Celestial Shine
 
Join Date: Dec 2010
Nature: Calm
Okay. So LLVM is a compiler. So what?!?

There's a lot of C/ C++ compilers. When I used to write c/ c++ I used Bloodshed Dev. My question is (since I don't know a lot about rom hacking) what does the LLVM have to do with Rom Hacking?
Reply With Quote
  #6  
Unread June 13th, 2011, 01:09 AM
Full Metal's Avatar
Full Metal
C(++) Developer.
 
Join Date: Jan 2008
Location: In my mind.
Age: 17
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to Full Metal
It takes C or C++ code...and compiles it.
You see, if you actually knew what you were talking about, you would know that devkitpro/advance generates HUGE and very terrible code ( as far as assembly and instructions go atleast ). Even optimizations don't do that much for it.
What this thing does is makes actual optimized code. IDK if it does anything about file-size compared to devkitpro ( I haven't used this thing just yet -- still -- ), but it definitely increases over-all performance of the .elf files generated. That's my comprehension anyways.
__________________
Full Metal.‎"Fearlessness in those without power is maddening to those who have it."

Reply With Quote
Reply
Quick Reply

Sponsored Links


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC. The time now is 08:01 PM.


Style by Perdition Haze, artwork by Sa-Dui.
Like our Facebook Page Follow us on TwitterMessage Board Statistics | © 2002 - 2013 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2013 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User posts belong to the user.