Re: Design ASM routine to be called from C
- From: Jack Klein <jackklein@xxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 23:02:12 +0000 (UTC)
On Sun, 12 Jun 2005 21:36:39 +0000 (UTC), "Matt"
<spamtrap@xxxxxxxxxx> wrote in comp.lang.asm.x86:
> Cheok Yan Cheng wrote:
> > 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?
>
> ANSI C doesn't specify which registers are used for what. It doesn't even
> specify how large short, int, & long are. It is convention that we preserve
> the contents of those registers. It is a UNIX standard, and it is a
> convention that the Microsoft platform also follows. There is no requirement
> that every C compiler generate code according to that convention, but for
> practical reasons every popular C compiler for these platforms will.
>
> -Matt
I'm sorry, but this is just plain silly. There is nothing in the
POSIX standard about what register usage is or should be on 32-bit x86
processors. UNIX existed long before the original 8086, let alone the
32-bit processors of today.
There isn't even a standardized ABI across different versions of UNIX
running on the same processor type, in general.
--
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
.
- Follow-Ups:
- Re: Design ASM routine to be called from C
- From: Jonathan Bartlett
- Re: Design ASM routine to be called from C
- From: spamtrap
- Re: Design ASM routine to be called from C
- References:
- Design ASM routine to be called from C
- From: Cheok Yan Cheng
- Re: Design ASM routine to be called from C
- From: Matt
- Design ASM routine to be called from C
- Prev by Date: Re: Design ASM routine to be called from C
- Next by Date: Re: SSE2 and MMX performace - Almost same when performing integer addition
- 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
|