Re: mixing C and assembly



On Fri, 25 Apr 2008 00:08:56 +0200, David Brown wrote:
Neil wrote:
Walter Banks wrote:

Neil wrote:

Walter Banks wrote:
Vladimir Vassilevsky wrote:

You have to resort to assembly in the two special cases:

1. The system level work like switching the contexts of the tasks, C
startup code, etc.

2. The parts of code where the performance is very critical.
In your second point I would qualify it to parts of code
requiring exact timing on anything that we have released
recently that seems to be the only limitation.


Do not forget the startup code

Our startup code is in C.

w..



I am not sure how that works. I am talking about the code that jumps to
main after setting up the C environment.

So is he.

There are small bits of the startup that must be in assembler (I use
embedded assembly within the C code - Walter uses C extensions in his
compilers that translate directly to matching assembly). But most of it
can be written perfectly well in C. For example, code to copy the
initialised data from flash to ram, and to zero the bss, can be written
in C.

I've written the startup code in C on the SDCC compiler and the small
C comiler. Basically the compiler did nothing and I had to do
everything. I basically wouldn't use this for professional work but
it was simple enough and I just managed everything.

--
Linux Home Automation Neil Cherry ncherry@xxxxxxxxxxx
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies
.



Relevant Pages

  • 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: 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: mixing C and assembly
    ... The system level work like switching the contexts of the tasks, ... startup code, etc. ...
    (comp.arch.embedded)
  • Re: Looking to buy a used embedded cross compiler
    ... cross compiler to 68000. ... MacMeth Modula-2 compiler on the Mac. ... along with the source of a 68000 assembler written in Modula2: ... things like startup code, code placement in ROM/RAM, etc. which some/ ...
    (comp.arch.embedded)
  • Re: Startup code
    ... >In my opinion, startup code is code executed from the reset of the CPU, ... >> The compiler vendor will not typically know how the processor ... >Again, all startup codes I have seen so far, were written in assembler. ... there is no environment set up yet to run ...
    (comp.arch.embedded)