View Single Post
Old 08-20-2002, 08:32 AM   #10 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
I'm not sure how the ANSI C standard relates to the compiler forcing a function to return a value, even if declared as void but I am failry certain that in C++ this would break the rules. Due to the name mangling that takes place, falsly returning an int may cause some confusion when linking to third party libraries. This may not be the case on return values however since I'm not positive these are part of the functions signature.

Regarding the registers used, it's all dependent on the compiler. If you are compiling using 32-bit alignment, then you will always see eax used, and in many cases it will be used simply for optimization.

The CPU cycles to do the following:
Code:
mov al, 0x04
push al
ret
Are exactly the same as:
Code:
mov eax, 0x00000004
push eax
ret
Naturally, this is only true for x86 architectures. PowerPC, Sparc, and other various systems use a totally different scheme during code generation as they don't even have an eax, ax, or al[ah] register.
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming is offline   Reply With Quote