flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > problem with double in invoke macro Goto page 1, 2 Next |
Author |
|
vid 08 Feb 2007, 16:27
madmatt: haha, good catch
can be easily fixed in macro, look for "match =double" and add possibility for - |
|||
08 Feb 2007, 16:27 |
|
madmatt 08 Feb 2007, 17:37
vid: thanks , However couldn't find what you suggested. I think I'll let Tomasz fix this one, my knowledge of the macro language is still near zip .
|
|||
08 Feb 2007, 17:37 |
|
vid 08 Feb 2007, 18:02
add this to macro "pushd" in "win32ax.inc":
Code: match pushd =- =double num,pushd value \{ \local ..high,..low virtual at 0 dq -num load ..low dword from 0 load ..high dword from 4 end virtual push ..high push ..low pushd equ \} |
|||
08 Feb 2007, 18:02 |
|
LocoDelAssembly 08 Feb 2007, 18:55
vid, I think that your code is enabling the possibility of doing "- double 5.0" instead of "double -5.0".
Anyway the following code works with the lastest FASM without any modification: Code: include 'win32ax.inc' .code start: invoke function, double -5.0 invoke MessageBox, 0, "Works Fine", "FASM test", 0 invoke ExitProcess, 0 function dd functionLabel functionLabel: retn 8 .end start |
|||
08 Feb 2007, 18:55 |
|
vid 08 Feb 2007, 19:11
Loco: oh sure, my mistake :]
you are right, it should work. I just realized that "match" can match more than 1 symbol. Haven't been dealing with FASM macros for some time. :S |
|||
08 Feb 2007, 19:11 |
|
madmatt 08 Feb 2007, 21:11
I updated my includes with the latest fasmw includes , and now it works right, thanks to all for your help .
|
|||
08 Feb 2007, 21:11 |
|
LocoDelAssembly 08 Feb 2007, 21:22
Even FASM 1.64 works. Maybe you weren't using FASM includes?
|
|||
08 Feb 2007, 21:22 |
|
madmatt 08 Feb 2007, 23:10
I use a modified include file, basically, I combined the win32a.inc and win32axp.inc into a single win32a.inc file. And it looks like I missed something the first time.
|
|||
08 Feb 2007, 23:10 |
|
Vasilev Vjacheslav 09 Feb 2007, 10:00
there are little problem with double in invoke macro, AFAIK, double is 8 bytes (2 DWORDs), but this code compiled with error (or i missed something?!)
Code: start: stdcall _test,double -5.0 invoke ExitProcess,NULL proc _test, param ret endp Code: push 40140000 push 0 call _test push 0 call ExitProcess _test: push ebp mov ebp,esp leave retn 4 <-------- must be 8? |
|||
09 Feb 2007, 10:00 |
|
vid 09 Feb 2007, 10:42
Vasil: you must define procedure argument as QWORD, or define two arguments. Otherwise assembler cannot figure out you want it to be qword
|
|||
09 Feb 2007, 10:42 |
|
Vasilev Vjacheslav 09 Feb 2007, 15:30
yes, it's needed to read fasm.pdf before asking stupid question, thanks
this code works ok Code: section '.idata' data readable writeable param dq 5.0 section '.code' code readable writable executable start: stdcall _test,double param invoke ExitProcess,NULL proc _test, param:QWORD ret endp _________________ [not enough memory] |
|||
09 Feb 2007, 15:30 |
|
LocoDelAssembly 09 Feb 2007, 15:47
Works but it doesn't pass 5.0 as parameter but a pointer to param and a NULL pointer instead.
The correct way Code: stdcall _test, double [param] BTW, I think that this one is a bug, the pushd macro should check if it really pushing a float. |
|||
09 Feb 2007, 15:47 |
|
LocoDelAssembly 09 Feb 2007, 18:01
At WIN32?X*.inc
Code: match pushd =double num,pushd value \{ \local ..high,..low virtual at 0 ; ### ADD THIS if ~num eqtype 1.0 display "Floating point value expected" err end if ; ### dq num load ..low dword from 0 load ..high dword from 4 end virtual push ..high push ..low pushd equ \} |
|||
09 Feb 2007, 18:01 |
|
Tomasz Grysztar 09 Feb 2007, 22:47
The "double" is just a 64-bit value, it doesn't necessarily need to be a float.
|
|||
09 Feb 2007, 22:47 |
|
LocoDelAssembly 10 Feb 2007, 00:20
Quote: If the parameter is preceded by the word double, it is treated as 64-bit value and passed to the procedure as two 32-bit parameters. For example: I found the name "double" not very good chosen then, if the word "double" is for passing a 64-bit value then why not providing the word "quad" instead? I mean, the word size of x86 architecture is 16 bits, so specifying "double" means a 32-bit value, but, if we think "double" as the HLL meaning (which the example in the quote suggests), and taking into account that the invoke macro is for provide some HLL construct, for me the appropiete behavior of "double num" is to allow only a float "num". All the above just IMHO of course |
|||
10 Feb 2007, 00:20 |
|
madmatt 10 Feb 2007, 06:38
loco: Naaaaaa , double is just fine, c++ uses double, along with all the .NET languages, and a lot of older langauges, like QuickBasic. Just remember, to pass a double to a function using var:QWORD in the proc header.
|
|||
10 Feb 2007, 06:38 |
|
Tomasz Grysztar 10 Feb 2007, 10:12
"double" means "double push" here: the two 32-bit parameters are pushed to the stack.
|
|||
10 Feb 2007, 10:12 |
|
madmatt 11 Feb 2007, 11:23
Still Having problems with the double, when I do this:
Code: double -1.5 It gives me an error, but when I do this: Code: double (-1.5) It works. I also have a function that won't compile for some reason: Code: invoke glutSolidSphere, double [resulta], 20, 16 It gives me an 'invalid parameter count', but the Parameter count is correct! For some reason it thinks the double keyword is a variable or something. |
|||
11 Feb 2007, 11:23 |
|
madmatt 11 Feb 2007, 12:58
I think I found the problem! After taking a closer look at the macro, I commented the 'err' word and everything worked! see below:
EDIT Correction, the negative values still give me problems, but the other error seems to be corrected. Code: macro invoke proc,[arg] \{ \common count@stdcall = 0 if ~ arg eq \forward count@stdcall = count@stdcall+1 match =double value, arg \\{ count@stdcall = count@stdcall+1 \\} \common end if if defined proc \# % if count@stdcall <> proc \# % display "Error: invalid count of parameters for ",\`proc,".",0Dh,0Ah ;err <-[RIGHT HERE] end if end if \reverse pushd <arg> \common call [proc] \} |
|||
11 Feb 2007, 12:58 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.