flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 23 Mar 2013, 22:19
Vitally important information: http://blogs.msdn.com/b/oldnewthing/archive/2013/03/22/10404367.aspx
It's a shame I can't remember the several threads this was discussed. |
|||
![]() |
|
bitRAKE 24 Mar 2013, 22:17
|
|||
![]() |
|
AsmGuru62 26 Mar 2013, 12:53
This code will never return -1:
Code: ; ; Main application message loop ; sub esp, sizeof.MSG mov edi, esp xor ebx, ebx @@: invoke GetMessageW, edi, ebx, ebx, ebx test eax, eax jz .game_over invoke TranslateMessage, edi invoke DispatchMessageW, edi jmp @r .game_over: add esp, sizeof.MSG ... |
|||
![]() |
|
MHajduk 28 Mar 2013, 21:33
bitRAKE wrote: I've used: |
|||
![]() |
|
bitRAKE 28 Mar 2013, 23:56
The comment on the code is error.
It actually should say: -,0,+ My (non-MS approved) assumption is that all negative values are errors - not just (-1). All positive values are assumed to be valid window messages, and zero is of course WM_QUIT. It's important to have the Z and S (O=0 too) flags set for the jump to operate effectively given these assumptions. Some might think CMP instruction must be needed to get the proper signed response -- I did, since TEST is a logical instruction. The comment is a reminder to myself that TEST works for signed evaluation because it clears the O flag. Imagine if we have a hash table using open addressing: We can use the bits of the pointer and this three-state trick to make the code more efficient: TEST EAX,$80000003. (When testing the state of the table entry.) |
|||
![]() |
|
baldr 29 Mar 2013, 07:23
bitRAKE,
Condition flags are hard to master, yet they're thankful when you did. Particularly PF can simplify efforts to detect bit combinations that are hard to identify using straightforward technique (test eax, 3/jpe equal jumps if lower two bits are equal). |
|||
![]() |
|
revolution 04 Apr 2013, 02:13
bitRAKE wrote: I've used: MHajduk wrote: bitRAKE, how do we know that 'GetMessage' function returns only those three values? MSDN states that "return value can be nonzero, zero, or -1" (kind of ridiculous redundancy, I know, because -1 is also nonzero value), so if there would be only -1, 0, and 1 they should say it explicitly. What for they have said "nonzero" instead simply "1"? Code: inc eax cmp eax,1 jb .return_value_was_negative_one je .return_value_was_zero ja .return_value_was_non_zero ;other tests possible also jae .return_value_was_not_negative_one jne .return_value_was_not_zero jbe .return_value_was_not_non_zero |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.