flat assembler
Message board for the users of flat assembler.
Index
> Windows > C++ vs Assembly: GetTickCount |
Author |
|
macomics 21 Jul 2022, 10:42
And now stuff this miracle in c++ into the disassembler and be disappointed in this short line.
Everything really will eventually come down to calling these WinAPI, but before that, c++ will do 100500 manipulations and checks with this data. For example: call [GetStdHandle], -11 (fasm) = stdout (c++) |
|||
21 Jul 2022, 10:42 |
|
revolution 21 Jul 2022, 11:05
I think it would be clearer if the -11 magic value was made into a constant definition.
Code: descriptive_name_for_value = -11 ;... push descriptive_name_for_value |
|||
21 Jul 2022, 11:05 |
|
FlierMate1 21 Jul 2022, 11:10
macomics wrote: And now stuff this miracle in c++ into the disassembler and be disappointed in this short line. I understand what you mean, the output executable would be larger and filled with additional code (although I haven't disassemble one myself ) revolution wrote: I think it would be clearer if the -11 magic value was made into a constant definition. STD_OUTPUT_HANDLE ((DWORD)-11), The standard output device. Yeah, my bad practice from the beginning to use the constant value instead of the constant name. But it is too late, it has been published. |
|||
21 Jul 2022, 11:10 |
|
revolution 21 Jul 2022, 12:33
How does C++ compare to this sequence?
Code: add eax,ebx rcr eax,1 ; (eax + ebx) / 2 without failure due to overflow Code: mul edx ; use full result in edx:eax Code: rep movsd |
|||
21 Jul 2022, 12:33 |
|
FlierMate1 21 Jul 2022, 13:56
No idea. I haven't done any real research into "C++ vs Assembly".
I will be glad if someone more knowledgeable could share his/her insights. |
|||
21 Jul 2022, 13:56 |
|
FlierMate11 24 Jan 2023, 15:30
A correction to the code at Post #1, should have used C calling convention for wsprintfA
Code: call [GetTickCount] ;push eax ;push fmt ;push buf cinvoke wsprintf,buf,fmt,eax mov dword [len], eax Thanks @sinsi for your confirmation on the other thread. |
|||
24 Jan 2023, 15:30 |
|
FlierMate11 24 Jan 2023, 15:38
FlierMate11 wrote: A correction to the code at Post #1, should have used C calling convention for wsprintfA After disassembly, cinvoke is actually Code: call [wsprintf] add esp, 0ch Why can't I use ccall?
|
||||||||||
24 Jan 2023, 15:38 |
|
revolution 24 Jan 2023, 15:42
FlierMate11 wrote: After disassembly, cinvoke is actually FlierMate11 wrote: Why can't I use ccall? Code: call wsprintf ; <- note there are no square brackets [] |
|||
24 Jan 2023, 15:42 |
|
FlierMate11 24 Jan 2023, 15:48
revolution wrote:
Thank you for the explanation. I see now why I failed to use ccall. |
|||
24 Jan 2023, 15:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.