PDA

View Full Version : GP2x: Make lean .gpe's from just Pascal+asm, not Delphi?



HenrikE
29-03-2008, 05:17 PM
I have the FPC4GP2x Delphi example "gp2x_tutorial" compiled and working on both Win and GP2x. But the filesize in 1MB(!)

I'd like to just use Pascal, no SDL or units above the bare bones. Also, I'd like to use inline assembler. I can already write some small routines with inline asm.

I have two questions,

1. I've figured out a bit of the assembler syntax, like .long, .align, etc from compiling Delphi programs and looking at the ppcrossarm source. I'm also fine with the instructions syntax. But where can I find official and complete docs of all the directives/symbols arm-linux-as.exe uses?

2. If i compile a .pp to an .o file, how do I make a .gpe? (gp2x executable binary file.) As soon as I use the linker, filesize skyrockets.

Legolas
29-03-2008, 05:30 PM
1. arm-linux-as is the GNU assembler (http://sourceware.org/binutils/docs/as/index.html)

2. in order to obtain an executable you'll need the linker. The size grows because the rtl linked to the executable. You could try to smartlink the executable and strip out debug infos (passing -XX -Xs to the compiler)

HenrikE
29-03-2008, 06:45 PM
A 350K pascal RTL? Unheard of :) I've written dozens of apps for MS-DOS back when Turbo Pascal was the fastest, leanest thing alive, and some of them were <2K in size.

Anyway, what I'm really looking for is a way to make a minimum .gpe, insert my asm, and discover the hardware :)

If someone has made a Pascal/Delphi app <350K, please tell me how you did it!

Legolas
29-03-2008, 07:55 PM
MS-DOS and Turbo Pascal are a way different from Free Pascal and linux. I've seen zillions of posts like this one degenerating in a flame about executables size, dependencies, rtl, cross compiling, and so on :)
In order to avoid it, take a deep breath and read this (http://wiki.freepascal.org/Size_Matters). :wink:

However, a way to obtain a bare bone executable as you want is to rewrite the rtl, stripping down all the stuff you don't need.
Another way is the one I used in the first steps of fpc4gba: call the compiler with -s (don't call assembler and linker), edit by hand the .s file cutting all RTL references, assemble and link it.

HenrikE
29-03-2008, 09:47 PM
Thanks a lot for helping me :) Although liking Pascal doesn't help if you'd like to make some small app and end up with big file sizes. Doc read and appreciated - I've no idea why the RTL is so small on MS-DOS/TP.

With help from oliebol in #fpc (many thanks!), it soon became clear that starting out from the SDL framework from the FPC4GP2X page was, not optimal if you need (not necessarily want, having come from IDEs ;)) to learn the arm-linux-*.exe tools and their options :)

Simply (if you know ppcrossarm can 'do it all') using ppcrossarm -dgp2x -CX -XXs -XParm-linux- myfile.dpr (or .pp) gave more acceptable results, 88K for dpr and 27K for pp.


Which leaves the final option, coding entirely in assembler. Wouldn't mind it, if I knew/had control over the final .gpe, i.e. that only the necessary bits surround the asm code, but that it's still a valid executable.

HenrikE
30-03-2008, 03:03 AM
OK, got my first little asm proggie working, and there really is little difference between Pascal and Delphi if no units are used. Pascal, 27K, Delphi, 28K.

Wee!

Tomorrow I'll try moving some pixels about... :)