flat assembler
Message board for the users of flat assembler.
Index
> Windows > check how many functions failed |
Author |
|
revolution 26 Mar 2014, 16:14
Use a table maybe:
Code: hot_key_table: dd VK_F5,VK_F1 dd VK_F6,VK_F2 dd 0 ;... xor edi,edi mov esi,hot_key_table .loop: invoke RegisterHotKey,0,dword[esi+0],0,dword[esi+4] test eax,eax setz al movzx eax,al add edi,eax add esi,8 cmp dword[esi],0 jnz .loop |
|||
26 Mar 2014, 16:14 |
|
cod3b453 26 Mar 2014, 17:13
Given that RegisterHotKey return type is BOOL, it might be as simple as invoke/add edi,eax with a cmp at the end.
|
|||
26 Mar 2014, 17:13 |
|
tthsqe 26 Mar 2014, 18:33
I don't think we can assume MS bool is 0 or 1, right?
I just had an idea for edi += BoolToInt(eax), I think it should work because adding eax to 0xFFFFFFFF only doesn't produce a carry when eax is zero. Code: ; increment edi if eax != 0 neg eax ; or add eax,-1 ; carry flag is now the bool represented by eax adc edi,0 ; increment edi by carry flag I don't think you can do do this with fewer than 2 instructions. Also, Code: ; increment edi if eax = 0 cmp eax,1 ; or sub eax,1 ; carry flag is now the bool represented by !eax adc edi,0 ; increment edi by carry flag Last edited by tthsqe on 27 Mar 2014, 03:31; edited 2 times in total |
|||
26 Mar 2014, 18:33 |
|
revolution 26 Mar 2014, 23:37
I think it is not safe to assume bool returns -1 for true. It might return +1, or 482. Glad to see tthsqe saw that. Anyhow, it hardly seems worth the effort to save a single instruction for an API call that executes an unknown number of instructions and in a place that is called only once upon program startup.
|
|||
26 Mar 2014, 23:37 |
|
baldr 27 Mar 2014, 01:50
tthsqe,
neg instruction does exactly that (sets CF if operand is non-zero, clears otherwise), though its primary function may render it unusable in this case. cmp eax, 1 could be better than sub eax, 1. |
|||
27 Mar 2014, 01:50 |
|
tthsqe 27 Mar 2014, 03:27
baldr, I though 'neg' doesn't affect carry flags, or is that 'not'? I don't know because I never use those...
Anyways I read the docs and changed my post. |
|||
27 Mar 2014, 03:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.