asm_freak posted on Aug 21 2006 at 09:36 AM said:
Hi at
I really enjoy the ARM CPUs with their powerful language set.
Is it possible to program the GP2X using only and alone GNU 'as'? No linking with ld or pre-processing with gcc.
The same way as it's done using
FASM. There, you must provide in your assembler code the structure for the PE-files yourself.
Why I am asking this? Because I don't like not to have maximum control of what binary file I'll get as result using ld and so on. There are some magic startup codes inserted using ld. What do they do? I'd prefer to construct the resulting ELF-(GPE-)file with all its structures on my own.
Just a plain WYSIWYG_in_your_executable-assembly on the GP2X would be cool. Some kind of coding .com-files in old DOS days. ;-)
So, possible or not?
Thanks and cheers
asm_freak posted on Aug 21 2006 at 09:36 AM said:
Hi at
I really enjoy the ARM CPUs with their powerful language set.
Is it possible to program the GP2X using only and alone GNU 'as'? No linking with ld or pre-processing with gcc.
The same way as it's done using
FASM. There, you must provide in your assembler code the structure for the PE-files yourself.
Why I am asking this? Because I don't like not to have maximum control of what binary file I'll get as result using ld and so on. There are some magic startup codes inserted using ld. What do they do? I'd prefer to construct the resulting ELF-(GPE-)file with all its structures on my own.
Just a plain WYSIWYG_in_your_executable-assembly on the GP2X would be cool. Some kind of coding .com-files in old DOS days. ;-)
So, possible or not?
Thanks and cheers
Absolutely, no problem at all...Well, not using LD means you have to write your own LD. You can keep ld out of your shorts. Or you could re-write it, but that is an all together different project, I would switch to some other assembler and linker first. AS far as assemblers go, gas for arm is ackward, it is what it is a kludge of a compiler written for another platform made to work for arm. Find an old copy of arm sdk or ads or something, maybe tcc if they have an arm port. Or just use ld, its not that painful, you can control it...
http://www.dwelchsoftware.com/arm-20060802a.zip should have some examples. Ideally you do want to replace your bootloader with the modified bootloader that lets you boot a .img file. From there it is pretty easy to build all asm programs.
As an alternative, and I think there are some examples above, you can run whatever you want on the 940, very little difference between the 940 and the 920, make your program use a loader program on the 920 (I can get you one if you dont have one, basically it is a modified version of rlyeh's stuff) Leave the 920 in an infinite loop and it will live in the cache and stay out of the way of the 940.
If you are talking writing linux/sdl apps in all asm. well of course you can do that too, write some test programs in C compile to asm and find out what if any name mangling and library calls you need to make then go all asm from there...
I have been off the gp2x for a couple of weeks now, got an Olimex SAM7S-H64 I have been playing with. GCC was killing me, no matter what I did it wanted to write to registers using strb instead of str, I hated the idea of making the write register function an asm function and having to eat the function call every time. The project was pretty simple had it mostly done in asm already, so I dumped gcc and finished in in asm only. Made life much easier. I enjoy letting the C compiler(s) with full optimizations try to optimize code for me, things like (( a>>2)&3)|((b&3)<<2) Sometimes the C compilers comp up with things I had forgotten about like orr r1,r2,r2, lsl #2. Saved me an operation...Then of course some times (often with gcc) it just digs a hole and takes the long road. The arm compilers, sdk, ads, rvct, are simply incredible, the instructions and instruction sequences generated (C code with full optimizations on) are a work of art.
Anything you can do in C or any other language you can do in ASM by definition. (the corrallary is not true).
p.s. all typos and spelling mistakes are intentional...