Re: Design ASM routine to be called from C



On Sun, 12 Jun 2005 20:59:11 +0000 (UTC), spamtrap@xxxxxxxxxx (Cheok
Yan Cheng) wrote in comp.lang.asm.x86:

> Hi, from the PC Assembly Language document written by Paul, I was
> understand that
>
> " C assumes that a subroutine maintains the values of EBX, ESI, EDI,
> EBP, CS, DS, SS, ES after function call "
>
> I hold this rule when I design my ASM subroutine which will be used in
> C program. For most of the register which is used (for example, EDX)
> in the subroutine, I didn't explicitly store (push) just after the
> call, and restore (pop) just before ret.
>
> However, I was wondering whether this rule is applicable to all the c
> compiler (gcc, visual c++......)? Is it an ANSI C standard?
>
> Thank you very much
>
> cheok

There is no ANSI C standard for register usage in C. There are no
processor or platform specific details in the C standard, precisely
because it must run on so many different processors and platforms. On
the PowerPC processor in a Macintosh or the ARM processor in embedded
devices, the registers are completely different and there are no "EBX"
or "DS" registers.

Every compiler should provide documentation of it's interface
requirements, in the printed manual, online help, or man pages.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

.



Relevant Pages

  • Re: Recursive Call
    ... On IBM mainframes there was/is a standard linkage convention to be followed ... Register 15 contains the "branch to" address and Register ... this save area at entry to the subroutine. ...
    (comp.lang.cobol)
  • Re: A new paradigm
    ... One driver with a standard interface to ... standardised subroutines - everything in my suites is a subroutine ... First I use a 3rd party btree handler for several reasons - cross ... but no one in the rest of the market seemed interested. ...
    (comp.databases.pick)
  • Re: creating directories on the fly
    ... Although the SYSTEM subroutine does not belong to the Fortran ... >> standard, i don't get an indication that I'm using an extension... ... Calling subroutines is not an extension. ... > existing standard intrinsics to be transitioned into modules, ...
    (comp.lang.fortran)
  • Re: creating directories on the fly
    ... Although the SYSTEM subroutine does not belong to the Fortran ... > standard, i don't get an indication that I'm using an extension... ... I'd be darned annoyed if any compiler ...
    (comp.lang.fortran)
  • Re: Modules and User Supplied Subroutine
    ... where aSubroutine is a user supplied subroutine. ... is to an external procedure with that name. ... the standard requires the external ... What does the standard say about linking in general? ...
    (comp.lang.fortran)