Page 1 of 1

What registers need to be saved?

Posted: Wed Mar 19, 2003 5:00 pm
by Unspoken_Magi
I know GCC doesn't want certain registers to be modified, but which ones?

I know it wants return in eax.
Should ebx, ecx.. etc. be saved? I know es, ds... etc. have to be saved..... because GCC doesn't want you to change them.

Re:What registers need to be saved?

Posted: Wed Mar 19, 2003 5:33 pm
by Ozguxxx
From http://my.execpc.com/~geezer/osd/libc/index.htm#call
check there for more info:
GCC expects functions to preserve the callee-save registers:
EBX, EDI, ESI, EBP, DS, ES, SS
You need not save these registers:
EAX, ECX, EDX, FS, GS, EFLAGS, floating point registers
In some OSes, FS or GS may be used as a pointer to thread local storage (TLS), and must be saved if you modify it.