flat assembler
Message board for the users of flat assembler.
Index
> Main > FPU and function call :) |
Author |
|
Matrix 21 Nov 2004, 16:41
its easy, you'll see read these:
Flat Assembler Frequently Asked Questions (FAQ) (main) wanderer's calculator: http://board.flatassembler.net/topic.php?t=2441 |
|||
21 Nov 2004, 16:41 |
|
denial 22 Nov 2004, 15:19
Thank you. But:
Neither the ... "FAQ" (I would maybe call it as some kind of "helper page", because it isn't really like a typical FAQ) nor the forum search helped me to find general informations about calling conventions. Maybe I'm just too stupid - but I searched about half an hour for this. Maybe somebody has got a direct link with some general information about this topic? It even got more confused because now I saw in other threads, that there are also other calling conventions like PASCAL... I would like to know the theory behind these things. Thank you again. |
|||
22 Nov 2004, 15:19 |
|
crc 22 Nov 2004, 15:55
Quote: What does this system mean and what exactly means the c-calling convention? In the C calling convention, you push arguments onto the stack; these are used by the function being called. The called function returns a value in eax, and you have manually clean up the stack by doing add esp, #bytes_pushed_to_stack. It's not the cleanest approach, but it does work pretty well. Obtaining a value in a C function is done by doing mov reg, esp+offset (or something like that; I don't delve into this very much). I hope this little bit of explaination helps... |
|||
22 Nov 2004, 15:55 |
|
vid 22 Nov 2004, 16:44
as crc said, plus you have to push arguments in reverse order (right to left in fuction declaration).
Code: ;C declaration int func(int arg1,int arg2,int arg3); ;calling from asm push arg3value push arg2value push arg1value call _func ;usualy there is a "_" before functions declared with C add esp,4*3 ;sizeof(int)*number_of_arguments |
|||
22 Nov 2004, 16:44 |
|
Matrix 22 Nov 2004, 17:48
sorry i forgot to mention, stdcall.inc in the fasm include files is for calling procedures ( it pushes parameters reverse order )
|
|||
22 Nov 2004, 17:48 |
|
crc 22 Nov 2004, 18:41
Quote: plus you have to push arguments in reverse order I suppose I should have mentioned that..... |
|||
22 Nov 2004, 18:41 |
|
denial 22 Nov 2004, 21:00
thank your for your answers
|
|||
22 Nov 2004, 21:00 |
|
THEWizardGenius 19 Jan 2005, 01:52
Yes. All you have to do is use FILD to copy an integer into floating point format, and FIST/FISTP to put it back into memory. You also have to load most constants, except one and zero- just use FLD1 and FLDZ to load those onto the FPU stack. The FPU stack is 8 registers set up as a stack. If you want to know where I learned all this, check out http://www.ragestorm.net/downloads/387intel.txt - it's the official programmers manual to the 80387. Newer extensions can only be found in PDF format that I know of, and you get the PDF's from the Intel developers page. Hope I could be of some help to you.
|
|||
19 Jan 2005, 01:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.