flat assembler
Message board for the users of flat assembler.
Index
> Windows > Help: Which register receives invoke results? |
Author |
|
revolution 03 Feb 2013, 13:30
1) In the Windows API returned values are always in eax.
2) The XOR reg,same_reg function always produces a zero result regardless of the incoming value of the register. It is commonly used in x86 code because the opcode is shorter than for MOV. But the XOR operation also affects the flags so you need to be aware of that. |
|||
03 Feb 2013, 13:30 |
|
AsmGuru62 03 Feb 2013, 13:41
XOR is a binary operation -- look into Wikipedia to see the logic of it.
But in simple programming terms it would be working like the following: Code:
XOR DESTINATION, SOURCE
If bit in SOURCE is 0 -- DESTINATION bit will not change If bit in SOURCE is 1 -- DESTINATION bit will invert its value Example: Code: SOURCE: 011011010101010100 DESTINATION: 000100111001000001 ------------------ RESULT: 011111101100010101 If SOURCE is the same as DESTINATION, then all '1' bits in DESTINATION will be inverted to '0' and that makes whole result to be zero: Code: SOURCE: 011011010101010100 DESTINATION: 011011010101010100 ------------------ RESULT: 000000000000000000 |
|||
03 Feb 2013, 13:41 |
|
f0dder 03 Feb 2013, 15:07
DennisFabian wrote: why does for example It's called "calling convention" - being a convention, it's the same across the entire Win32 API. DennisFabian wrote: In other programming language we have to give another variable name like: x86 instructions tend to have hardcoded destination; other achitectures might define the instruction as "XOR destination, operand1, operand2", but for x86 doesn't. With intel assembly syntax, the first operand is usually re-used for destination (but then there's stuff like MUL and DIV with fixed output registers). I suggest you download The Manuals and browse through - they are massive, though. There's also a bit here that's slightly more digestible, and the book project at the asmcommunity (haven't really looked much at it, and it seems page ordering is alphabetized instead of logical progression). I also recall FASM.PDF being a decent read. _________________ - carpe noctem |
|||
03 Feb 2013, 15:07 |
|
DennisFabian 03 Feb 2013, 16:28
Thanks for all the replies!!
Haha. I know what xor means and what it does! I just wanted to know why the result of the operation gets saved in eax too. Thank you for all the answers! You helped me alot!! |
|||
03 Feb 2013, 16:28 |
|
AsmGuru62 03 Feb 2013, 16:34
The 1st operand in ASM instruction is USUALLY the one that is a destination,
the one that will be modified as a result of the instruction. |
|||
03 Feb 2013, 16:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.