flat assembler
Message board for the users of flat assembler.
Index
> Main > Doubt with TEST instruction |
Author |
|
revolution 28 Mar 2008, 11:31
TEST is just a binary AND of the two operands. FLAGS = (EDI AND 0x00000003). Check out the Intel/AMD manuals for details on all the instructions. If you haven't yet downloaded the manuals check out my website, all the details are there.
|
|||
28 Mar 2008, 11:31 |
|
DJ Mauretto 28 Mar 2008, 11:32
Hello
Code: test edi, 3 ; EDI AND 11B jnz short some_func ; Jump if bit0 or bit1 are set |
|||
28 Mar 2008, 11:32 |
|
Cthulhu 28 Mar 2008, 11:37
DJ Mauretto wrote: Hello [code] Hi DJ Mauretto! I understood that from the Intel Manual but what is confusing me is that EDI points to 0x00000000 so the bits 0 and 1 are not set, aren't they? So why ze zero flag was set? |
|||
28 Mar 2008, 11:37 |
|
DJ Mauretto 28 Mar 2008, 11:43
Code: EDI = 0 TEST EDI,3 = 0 AND 3 = 0 = Zero Flag Set JNZ short and so on.... NO JUMP because is Zero |
|||
28 Mar 2008, 11:43 |
|
Cthulhu 28 Mar 2008, 11:46
DJ Mauretto wrote:
Now I understand it! Thanks friend! |
|||
28 Mar 2008, 11:46 |
|
revolution 28 Mar 2008, 11:50
Cthulhu wrote: ... what is confusing me is that EDI points to 0x00000000 so the bits 0 and 1 are not set, aren't they? So why ze zero flag was set? If you want to test the memory address pointed to by EDI use any of these: Code: test dword[edi],3 test word[edi],3 test byte[edi],3 |
|||
28 Mar 2008, 11:50 |
|
Cthulhu 28 Mar 2008, 12:10
Thanks a lot revolution and DJ Mauretto!
|
|||
28 Mar 2008, 12:10 |
|
AlexP 28 Mar 2008, 21:20
Code: ; C-Style If (edi % 4 == 0) ; code Else ; here's the jump destination Is equal to this in ASM: Code: test edi,3 jnz .end ; code .end: ; here's the jump dest. It's in Intel Optimization Manual, I use it for conditional jumping with power-of-two operand. |
|||
28 Mar 2008, 21:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.