Re: Startup code



In article <d9tsta$po7$1@xxxxxxxxxxxxxxxxxxxx>, Jet Morgan <jm@paran---
andr---.wanadoo.co.uk> writes
>
>"Meindert Sprang" <mhsprang@xxxxxxxxxxxxxxxxxxx> wrote in message
>news:11c4t1rcaohggba@xxxxxxxxxxxxxxxxxxxxx
>
>> I'd like to disagree with this. In all compilers I used so far, the
>startup
>> code only set's up the very basic things like the stack pointer, code and
>> data segments dependig on the CPU used and initializing all variables and
>> constants.
>
>> The rest, like further processor and peripheral initialisation is
>> done in user written C functions.
>
>That is still startup code, even if written in C.
>
>And so far, I have never written start up
>> code, I could always use the start up code supplied by the compiler
>vendor,
>> which is automatically chosed and configured by most IDE's.
>
>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.
>
>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.
>
>Richard [in PE12]
>
>

Start up code is the minimum code required to get to main... The start
point of the C code.

It depends on the processor how much start up code there is. This is
usually a file supplied with the compiler. I have know embedded C
programmers never realise there was start up code before the main as the
compiler added it transparently. This file is of course is all written
in assembler.

On some MCU some people modify this start up assembler. Most don't. On
other MCUs the start up file is a template that the user has to set up
various variables (stack, memory, clocks etc.).

So the answer as to what is start up code is "it depends" but it usually
refers to the assembler that sets up enough of the MCU so that the C
program can start at main.

Note strictly speaking if you are using start up code there is no OS and
therefore the first C function is not required to be called main.


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



.



Relevant Pages

  • Re: Startup code
    ... That is still startup code, ... The compiler vendor will not typically know how the processor ... written my startup code in a combination of C and assembler. ...
    (comp.arch.embedded)
  • CLR Mixed mode compilation woes!
    ... something to do with the stack frame ... corruption. ... C libs etc and on startup loads C Dlls? ... How can i specifically instruct the compiler to only compiler specific ...
    (microsoft.public.dotnet.languages.vc)
  • csc is launched during BDS 2006 startup
    ... compiler) is launched. ... And this is not the first time I start BDS 2006. ... Why does C++Builder requires a csc compilation at every startup? ...
    (borland.public.delphi.non-technical)
  • Re: Evaluating D2005, Memoryloss
    ... If we suppose the ProcessExplorer is showing the actual compiler leak, then may be the tests I've made are interesting. ... After startup: ...
    (borland.public.delphi.non-technical)
  • Re: What micros do you actually hate to work with?
    ... with less than tiny asm ... hassle to work with 32 bit longs in assembler for an 8 bit uP, ... Microchip's C compiler tools and their assembly under MPLAB. ... is that other programmers for C are easier to find. ...
    (comp.arch.embedded)