Re: Calling convention odd?

"Qyz" wrote:
Hi all,

While doing some asm coding recently I noticed that
when I called _malloc, my ECX register was getting trashed.
I did some digging and was surprised to learn that this is
normal, that callers to C library routines are expected to
save EAX, ECX, and EDX.

Seems to me that if one is doing a lot of such calls,
it is best to not use ECX and EDX for local variables at all,
lest one has to push/pop over and over which is more expensive
than storing data on the stack.

My question is, what is the historical basis for this

perhaps it came from the original naming of registers
and their dedicated use in most complex instructions:

0 Accumulator
1 Count
2 Data
3 Base
4 Stack Pointer
5 Block Pointer
6 Source Index
7 Destination Index

It seems ironic that given a CPU architecture like
x86 that has so few registers, a practice like this
is in place that discourages use of registers.

I don't use any C-stuff nor the so commen calling convention,
so I got seven registers free for anything desired, but also
then register are used mainly as instructions are designed.

btw: pushad/popad timing isn't too bad (~ like three push/pop-reg).