Re: Design ASM routine to be called from C
- From: Jack Klein <jackklein@xxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 23:01:26 +0000 (UTC)
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
.
- References:
- Design ASM routine to be called from C
- From: Cheok Yan Cheng
- Design ASM routine to be called from C
- Prev by Date: Re: SSE2 and MMX performace - Almost same when performing integer addition
- Next by Date: Re: Design ASM routine to be called from C
- Previous by thread: Re: Design ASM routine to be called from C
- Next by thread: Re: Design ASM routine to be called from C
- Index(es):
Relevant Pages
|