This is a discussion on assembly help within the C Programming forums, part of the General Programming Boards category; Originally Posted by MacNilly Yes, but those are C functions, I don't see any return statements. (in the OP post) ...
i only want was the logic !!
and i think, its sufficient to try with.
You don't return values in assembler. This is a feature of the C language. You can basically return values in any explicit return register in assembler. For instance I could set up the ECX register to hold a value and then call another function.Where is the return value being returned in any of these functions?
Integral return values are returned in EAX and float values are returned in ST(0) in C.
Usually, return values in assembler is carried out through stack manipulation. By putting the return value in top of the stack. But this was interesting since the return value is stored in a different register, where that would be refereed to get the value.
x86 convention is to pass parameters to a function via the stack, but receive return values in EAX. If you're receiving a 64-bit number on a 32-bit system, I believe the convention is to store the most significant DWORD in EDX and the least significant DWORD in EAX.
As Bubba said, floating point numbers have their own convention within the x86 convention.
Technically, you could write your assembly code anyway you want. You don't necessarily have to even call a function, but you could technically just jump all over the place. You could even decide from inside a function that you don't like the return location, and decide on the fly where to return to. Needless to say, that's dangerous.
Although it's kind of obvious, it's good to stick to conventions so you can be sure your code will play nice with other code.