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.

DS development > implementing dynamic code loading - any ideas/hints?

#134309 - silent_code - Thu Jul 12, 2007 12:49 pm

hi there!

i was wondering what i need to implement dynamic code loading. what i mean by dcl is e.g. ai routines, that don't have to be in memory all the time when the corresponding agents aren't in use and won't be for a long time (like when they aren't in a certain level).

i guess i have to use some relocation code (does the nds have a mmu? i remember the gba had one, but i'm not sure and too short on inet time for checking) etc.

but my biggest problem is: how can i generate a file that will contain executable code to be loaded on runtime? are these .elf or .o files? i really have next to no idea about compilers. i understand them and languages in general and how to use them in a way to get my stuff done, but that's it - i have no special knowledge about e.g. gcc.
furthermore, how can i access and alter (relocate) symbols?

you're welcome to give me tips and hints, it doesn't matter if it applies to c or c++ (just make a note to *what* i applies). alternatively you could also post a link to a tutorial or some online book or (legal) ebook (no money for real books atm) to read up on the topic.

otherwise i had to implement an interpreter, but i'd rather chose the way of native code.

thank you very much!


and remember, only a respectful post is a very good post, that can help a lot! ;^D

#134313 - OOPMan - Thu Jul 12, 2007 1:11 pm

There has been a fair bit of discussion on this before...

The DS has an MPU, not an MMU, which makes things more difficult, but not totally impossible :-)

Try searching for the Topic called "Building an OS" which I started. The initial topic was dynamic code loading, but it quickly turned into an OS thread...
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#134357 - DragonMinded - Thu Jul 12, 2007 5:50 pm

Alternatively, you can check out the source to my DSOrganize or moonshell as both have a plugin/exe structure and code relocation. The method is kind-of ghetto (ie doesn't load full elf files and relocate all symbols) but it is plenty fine if you want a standard ai plugin type that can be loaded easily.
_________________
Enter the mind of the dragon.

http://dragonminded.blogspot.com

Seriously guys, how hard is it to simply TRY something yourself?

#134480 - silent_code - Fri Jul 13, 2007 11:07 am

thanks for the responses!
i'll take a look at the stuff.

so, it's possible to compile like any ordinary program and load the stuff needed for execution - with any compiler tricks involved, right? just load the .elf do the (partial) relocation, look for main() and execute it... sounds like a bit of work, but nothing impossible. hope i'll manage to get it working. :^)

OOPMan, did it work or did you stick with lua?