Re: mixing C and assembly





Mark Borgerson wrote:

In article <480F2B12.69B62031@xxxxxxxxxxxxx>, walter@xxxxxxxxxxxxx
says...


Chris H wrote:

As has already been mentioned the start up code has to be in assembler
as it sets up the memory for the stack etc however if you use the
standard one that comes with the compiler you will never need to see it.

There is no requirement for the start up code to be in asm. A lot of
compilers come with asm sample startup but the code could have
been written in C in the same compiler. The same extensions that
support embedded systems make this possible

Just out of curiosity, how do you set the initial value of the
stack pointer in C?

Most embedded systems compilers have extensions that
support processor register access. A lot of the compilers
were implemented from hosted compilers as a base and the
initial startup code was written before they added support
for processor access. The example startup has often been
this early code. My point is that it can be done in C.

In our case the first C compiler was written for the C6805
and that was based on a 6805 mistral compiler we had written
a few years earlier. Our initial startup code was written
in C on a compiler that would support it.

register_sp SP;

SP = int_value;

w..


.



Relevant Pages

  • Re: How function calls work
    ... >Offhand I don't remember exactly when dedicated hardware to support a ... >stack was added. ... that's basically isomorphic to "has Greg Comeau ... >gotten an order to port his compiler to one of these machines?" ...
    (comp.lang.cpp)
  • Re: How function calls work
    ... >> Some machines don't even have a stack. ... Offhand I don't remember exactly when dedicated hardware to support a ... gotten an order to port his compiler to one of these machines?" ...
    (comp.lang.cpp)
  • 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: Just what makes an architecture "C Friendly"?
    ... output code, how much support are provided by the compiler libraries, ... Easy stack manipulation. ...
    (comp.arch.embedded)