Re: Startup code



In article <11c4uoqp2qdc8f5@xxxxxxxxxxxxxxxxxx>, Meindert Sprang
<mhsprang@xxxxxxxxxxxxxxxxxxx> writes
>"Jet Morgan" <jm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>news:d9tsta$po7$1@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> That is still startup code, even if written in C.
>
>In my opinion, startup code is code executed from the reset of the CPU,
>until the call to main().
>So any function you call from main() to setup up further things, no matter
>how low level and essential they are, is not called startup code.

I agree. However as many don't ever see the start up ASM they forget it
is there and refer to the initial C functions as set up code.

>> The compiler vendor will not typically know how the processor
>> is connected to the other devices, such as memory bus widths,
>> clock timings etc. That's why YOU (the designer) has to write it.
>
>If need be, yes.

In this case it is usually changing values a template start up file. It
is VERY rare that anyone does more than modify the file that comes with
the compiler.

Does anyone have an example where you have to write the whole start-up
file yourself?

>
>> There seems to be this perception that startup code is specifically
>> assembler. It *could* be written that way but I've always
>> written my startup code in a combination of C and assembler.
>
>Again, all startup codes I have seen so far, were written in assembler.

The have to be as the start up code gets you to the start of the C
program. After that it is application code?

>Probably because at startup time, there is no environment set up yet to run
>compiled C code at all.

That is why it is called start up code. (and has to be written in
assembler)

> But this only holds true with "my" definition of
>startup code, where the call to main() is not executed yet.
>
>Meindert

Well in my experience I would have to agree with you.


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ chris@xxxxxxxxxxxx www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



.



Relevant Pages

  • Re: No wars
    ... > assembler, because you can look at the compiler output to see how the ... > compiler is doing things, you can concentrate on learning things one at ... familiar with that has inline assembler capacity, ... and going without all of the difficult startup code. ...
    (comp.lang.asm.x86)
  • Re: 80186 free C compiler
    ... I am new to all this but I am about to try my first embedded design using an 80C186 processor. ... Is there a free C compiler available? ... some custom startup code to get rid of the dependency on DOS. ... to get by with the DJGPP MS-DOS compiler if you can limit the processor ...
    (comp.arch.embedded)
  • Re: compiling m-files (graphical interface)
    ... Are you sure you've purchased the compiler add-on ... the structure in the startup code using the loadfunction. ... Now that you've read in the settings from the prior run, you use the setfunction to send those checkbox values, popupmenu strings, etc. to the controls that need them. ... Anytime you click on a control that you wish to save the settings for, in its callback function, you need to update the settings structure with the new value of the control and save it to the mat file using ...
    (comp.soft-sys.matlab)
  • Re: Startup code
    ... In my opinion, startup code is code executed from the reset of the CPU, ... things that need to be done before the main part of a program can run - setting up critical hardware, setting up the stack, clearing out bss, copying initial data segments, copying program data from flash to ram, calling C++ constructors, starting main, initializing other hardware and software. ... Code for setting up the stack, clearing bss, and copying the initial data segment is generally part of the "crt0" module that comes with your C compiler. ... It's frequently written in assembler, ...
    (comp.arch.embedded)
  • Re: mixing C and assembly
    ... The system level work like switching the contexts of the tasks, ... Do not forget the startup code ... There are small bits of the startup that must be in assembler (I use ... I've written the startup code in C on the SDCC compiler and the small ...
    (comp.arch.embedded)