ObjectOriented
24-Oct-95 14:21:52
Sb: #48625-ObjectOriented
Fm: Werner Kazmierzak 100041,1320
To: Ian J. Einman 74271,2766
Ian,
>> AddPower written in assembly is about 18K in size. Wow, pretty small
>> for all it does. The same thing (with a much improved interface, and
>> a few more features) is about 100K in C
well, I solved this kinda problems by
(1) not linking with c.o, but wrote my own startup code (derived from
the C= provided startup.asm routines),
(2) not using any C math, but linking with my own (assembly) routines,
(3) not linking with sc.lib or whatsoever (using amiga.lib only),
(4) using Printf() instead of printf() and the like,
(5) not using any global variables (only constants),
(6) … (more the like)
I write modules that need a lot of local variables in C (because of the benefit
of automatic variable adressing), and write those that are critical for speed
in ASM (using the link/unlk scheme for local variables).
For the need of global variables (that have to be accessible by all the
modules), I define a global data structure, and allocate memory space for it in
the startup code. This also makes the code reentrant and pure.
The pointer to this global data structure, is kept in the Task.tc_UserData
field, and can be easily found by FindTask(NULL)->tc_UserData.
So, in my projects, I combine the benefits of both C and ASM.
>> >>assembler will produce the most efficient programs of them all.
>>
>> Absolutely correct.
Well, some of my routines that I ported from ASM to C, compiled into more
effictive code. When I looked at it later with a disassembler, I sometimes
found some tricky optimations as well as stack and register usage I didn't even
think of when I developed it using ASM.
– wkc – … via AP from Hamburg, Germany