eflags

How are the SCAS and MOVS instructions affected by the value of the direction EFLAG?

折月煮酒 提交于 2019-12-24 10:49:32
问题 I want to know how setting or clearing the direction EFLAG changes how the SCAS and MOV instructions decrement or increment registers. I read some webpages and made the following assumptions I will list below. I am using the MASM 32 SDK - no idea what version, I installed via Visual MASM's download and installation wizard - with Visual MASM to wright and MASM32 Editor to link and build them into objects and executables. I use a Windows 7 Pro 64 bit OS. SCAS The SCAS instruction "compares a

Direction Flag in x86

孤街醉人 提交于 2019-12-18 05:59:10
问题 I am unable to understand how does the direction flag work in x86 . The text in my lectures say that it increments or decrements the source or destination register but that does not make sense with its name. Can someone explain what it does? 回答1: This flag is used in string operations, and specifies if strings begin at a low address and proceed to higher addresses or vice versa. For string instructions, ECX has the number of iterations, DS:ESI has the source address and ES:EDI has the

Direction Flag in x86

蓝咒 提交于 2019-11-29 10:46:56
I am unable to understand how does the direction flag work in x86 . The text in my lectures say that it increments or decrements the source or destination register but that does not make sense with its name. Can someone explain what it does? This flag is used in string operations, and specifies if strings begin at a low address and proceed to higher addresses or vice versa. For string instructions, ECX has the number of iterations, DS:ESI has the source address and ES:EDI has the destination (hence the s in ESI and the d in EDI ). After each iteration, ECX is decremented by one, and ESI and

How can I set or clear overflow flag in x86 assembly?

拈花ヽ惹草 提交于 2019-11-28 14:16:14
I want to write a simple code (or algorithm) to set/clear overflow flag. For setting OF, I know that I can use signed values. But how can I clear that? user1354557 There are many possible solutions. For instance, test al, al will clear the OF flag without affecting register contents. Or, if you don't want to affect the other flags, you can just directly modify the *FLAGS register. For example, in 32-bit, this would look like: pushfd ; Push EFLAGS onto the stack and dword [esp], ~0x800 ; Clear bit 11 (OF) popfd ; Pop the modified result back into EFLAGS Edit: Changed or al, al to test al, al

Assembly - JG/JNLE/JL/JNGE after CMP

时间秒杀一切 提交于 2019-11-26 19:31:20
I don't understand the JG/JNLE/JL/JNGE instructions, which come after CMP. for example, If I have: CMP al,dl jg label1 When al=101; dl =200 . On what we ask the jg ? Is it on al>dl ? or al-dl>0 ? Same prolbem on the next code: test al,dl jg label1 I don't understand what we compare, and on what we ask the " jg ". In other words, I don't understand when we would jump to label1, and when we wouldn't. When you do a cmp a,b , the flags are set as if you had calculated a - b . Then the jmp -type instructions check those flags to see if the jump should be made. In other words, the first block of

How to read and write x86 flags registers directly?

北慕城南 提交于 2019-11-26 12:27:15
问题 From what I\'ve read, seems like there are 9 different flags. Is it possible to read/change them directly? I know I can know for example if the zero flag is set after doing a cmp/jmp instruction, but I\'m asking if it\'s possible to do something like mov eax, flags or something. Also, for writing, is it possible to set them by hand? 回答1: Some flags can be set or cleared directly with specific instructions: CLC, STC, and CMC: clear, set, and complement the carry flag CLI and STI: clear and set

Assembly - JG/JNLE/JL/JNGE after CMP

心已入冬 提交于 2019-11-26 12:16:39
问题 I don\'t understand the JG/JNLE/JL/JNGE instructions, which come after CMP. for example, If I have: CMP al,dl jg label1 When al=101; dl =200 . On what we ask the jg ? Is it on al>dl ? or al-dl>0 ? Same prolbem on the next code: test al,dl jg label1 I don\'t understand what we compare, and on what we ask the \" jg \". In other words, I don\'t understand when we would jump to label1, and when we wouldn\'t. 回答1: When you do a cmp a,b , the flags are set as if you had calculated a - b . Then the