AHCC startup code

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

AHCC startup code

Postby simonsunnyboy » Thu Jan 17, 2013 6:35 pm

I noticed the default startup code for AHCC is provided as a .C file in the source package.
I have a few customizing questions (and want to share them publically).

I was wondering if it was possible to integrate my setup codes into a reusable startup package to reduce overhead of rewriting init codes.

Is it save to remove the unnecessary stuffs like command line parsing and library interfacing?
Would it be possible to add more initialization code like setup of graphics and running main in supervisor?
Can the startup file provide C/ASM functions to other .C files in the project with an appropriate header file?

Main aim is to produce a simplified startup module that will feature routines from my own libraries in one single package.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1922
Joined: Sun Jul 31, 2011 1:11 pm

Re: AHCC startup code

Postby Eero Tamminen » Thu Jan 17, 2013 11:06 pm

simonsunnyboy wrote:I noticed the default startup code for AHCC is provided as a .C file in the source package.
I have a few customizing questions (and want to share them publically).

I was wondering if it was possible to integrate my setup codes into a reusable startup package to reduce overhead of rewriting init codes.

Is it save to remove the unnecessary stuffs like command line parsing and library interfacing?
Would it be possible to add more initialization code like setup of graphics and running main in supervisor?
Can the startup file provide C/ASM functions to other .C files in the project with an appropriate header file?

Main aim is to produce a simplified startup module that will feature routines from my own libraries in one single package.


The purpose of the startup code is the do the minimum (as it's linked to all binaries) that a standards compliant C-program needs, argument parsing (with ARGV), setting up atexit/library constructor/destructor hooks etc. Anything else belongs to libraries that are linked separately and which functiosn are called separately.

Some toolchains (like GCC) provide also more minimal version of the startup code which can be just setting the stack and reducing memory allocated to the program. This is something that can be linked instead the standard startup code in programs that don't handle command line options (like ACCs), but they're always toolchain specific, whereas the standard startup code is often linked automatically.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Sat Jan 19, 2013 11:23 am

The question deals with possibilities and technical implementations, not C structure philosophy. You may stick to whatever you feel is right, that's your business. I'm interested in finding new ways to speedup development for Atari stuffs.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: AHCC startup code

Postby Henk Robbers » Mon Jan 21, 2013 5:23 pm

simonsunnyboy wrote:I noticed the default startup code for AHCC is provided as a .C file in the source package.
I have a few customizing questions (and want to share them publically).

I was wondering if it was possible to integrate my setup codes into a reusable startup package to reduce overhead of rewriting init codes.

Is it save to remove the unnecessary stuffs like command line parsing and library interfacing?
Would it be possible to add more initialization code like setup of graphics and running main in supervisor?
Can the startup file provide C/ASM functions to other .C files in the project with an appropriate header file?

Main aim is to produce a simplified startup module that will feature routines from my own libraries in one single package.


You can do anything you like in the startup code.
Setup of the stack is mandatory.
parsing a commandline is not, but does no do any harm.
Preparing stuff for libraries depends on your library usage.
Pure C libraries do not need preparation in the startup.
AHCC's standard lib needs some setup.
Of course when your own libs need preparation, you can put such code in the startup.


Sorry for the late reply. I have been in hospital for a few weeks.

Henk Robbers.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Mon Jan 21, 2013 5:30 pm

Late replies are still ok. All the best to recover your health!

I will experiment a bit and see what I can do.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1922
Joined: Sun Jul 31, 2011 1:11 pm

Re: AHCC startup code

Postby Eero Tamminen » Tue Jan 22, 2013 8:51 pm

simonsunnyboy wrote:The question deals with possibilities and technical implementations, not C structure philosophy. You may stick to whatever you feel is right, that's your business. I'm interested in finding new ways to speedup development for Atari stuffs.


Well, the problem was that I don't see why doing something like that would speed development of Atari stuff, it only makes your stuff incompatible with every other Atari C-compiler...?

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Wed Jan 23, 2013 4:18 pm

I don't want to compile my stuffs with another compiler. It produces a .TOS or .PRG file that is distributed and that's it.
It speeds things up if i don't have to bother with certain initializations anymore if they are simply in place and do work.
I'm not developing unixy or GEMmy stuffs here...all for demos and games under plain TOS.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: AHCC startup code

Postby Nyh » Wed Jan 23, 2013 4:29 pm

simonsunnyboy wrote:I don't want to compile my stuffs with another compiler. It produces a .TOS or .PRG file that is distributed and that's it.
It speeds things up if i don't have to bother with certain initializations anymore if they are simply in place and do work.
I'm not developing unixy or GEMmy stuffs here...all for demos and games under plain TOS.

So make a function void do_simonsunnyboy_init(void) and cal that function as the first thing in main. This way everything keeps working even when you try to compile nyh_great_stuff.c which assumes a normal c compiler.

Hans Wessels

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Wed Jan 23, 2013 4:31 pm

Basically I want to move these into a different startup file so it is transparent and I don't have to call it from main or any other function anymore.
Then all I have to change is my .PRJ file to use the new startup and the other code can concentrate on the things I want to code.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: AHCC startup code

Postby Henk Robbers » Fri Jan 25, 2013 10:18 pm

simonsunnyboy wrote:Basically I want to move these into a different startup file so it is transparent and I don't have to call it from main or any other function anymore.
Then all I have to change is my .PRJ file to use the new startup and the other code can concentrate on the things I want to code.


Your approach is correct. That's why the startup code is open.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Sat Jan 26, 2013 9:37 am

As a sidenote, tweaking the startup code is not only common but necessary on almost all embedded platforms. Guess why all manufacturers of embedded boards supply a package with linker scripts and startup files?

For AHCC all I need to know is for the .PRJ file. Do i simply state my own startup file (as a tweaked .c file) first or do I have to compile the startup seperately andf then link the .o file as with the default startup code?
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1922
Joined: Sun Jul 31, 2011 1:11 pm

Re: AHCC startup code

Postby Eero Tamminen » Sat Jan 26, 2013 11:35 am

simonsunnyboy wrote:Basically I want to move these into a different startup file so it is transparent and I don't have to call it from main or any other function anymore. Then all I have to change is my .PRJ file to use the new startup and the other code can concentrate on the things I want to code.


And re-apply your startup changes whenever Henk releases a new AHCC version that has features/fixes you want... And the sources won't work for others, unless they apply the same changes to their version of AHCC.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Sat Jan 26, 2013 12:00 pm

What changes? It is my .C or .O file that is located on my harddisk. All I have to do is copy this to a folder which my .PRJ file then references?
This breakes nothing for anybody. Each and every C project can have its entire own set of files. Not a single library is ever forced to be used. Everything needed is the startup which interfaces the user main program with the compiler - and that's it.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: AHCC startup code

Postby Henk Robbers » Sat Jan 26, 2013 2:53 pm

simonsunnyboy wrote:For AHCC all I need to know is for the .PRJ file. Do i simply state my own startup file (as a tweaked .c file) first or do I have to compile the startup seperately andf then link the .o file as with the default startup code?


There is nothing special. Any file appearing in the prj as first will be compiled if .s or .o
This simply means that the linker is not interested in sartup code at all.
The first object file coming out of the compilation process will be the first to appear in the executable.
The OS will start your executable at the first instruction of the first text segment appearing in the executable.
So you can have as many startup files as you think is usefull.
At least one of them must do the minimal preparation, then one of them must call 'main' (C standard).

It is up to the programmer to do things correctly (as always :-).

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Sat Jan 26, 2013 5:44 pm

Ahh I understand. So the startup code is normally linked first to ensure it is run at start and then handles everything to turn over the control to the other modules.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: AHCC startup code

Postby Henk Robbers » Sat Jan 26, 2013 10:39 pm

simonsunnyboy wrote:Ahh I understand. So the startup code is normally linked first to ensure it is run at start and then handles everything to turn over the control to the other modules.


LD: input files will appear in the output file (when something in them is referred to) in the same order
as in the project file. So the first real file in the project file whether .c, .s or .o is by definition the startup code.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1922
Joined: Sun Jul 31, 2011 1:11 pm

Re: AHCC startup code

Postby Eero Tamminen » Sat Jan 26, 2013 10:55 pm

Sorry, I somehow was thinking about other compilers where the default startup code is linked implicitly and changing the default startup code means messing with the toolchain files (or adding quite a few extra things to compiler command line). I somehow forgot that in AHCC one always specifies the startup code explicitly... :-/

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC startup code

Postby simonsunnyboy » Sun Jan 27, 2013 8:51 am

Most compilers I have seen allow custom startup code aswell. GCC, SDCC, Keil C, IAR, all serious ones come to mind. I'm pretty sure the Renesas Compiler and Tasking allow it too. Implicit linking can be overridden in most cases, e.q. SDCC.

Ofcourse this might not apply to some Windows compilers ;)
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 2 guests