Questions tagged [eflags]

EFLAGS refers to the flags register of the x86/x64 architecture.

EFLAGS refers to the flags register of the x86/x64 architecture. See https://en.wikipedia.org/wiki/FLAGS_register for details.

100 questions
61
votes
4 answers

Assembly - JG/JNLE/JL/JNGE after CMP

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…
Adam Sh
  • 8,137
  • 22
  • 60
  • 75
30
votes
2 answers

Carry Flag, Auxiliary Flag and Overflow Flag in Assembly

I Cannot seem to tell the difference between the Carry Flag, Auxiliary Flag and Overflow Flag in Assembly. I'm currently studying it in school and the teacher didn't go into any details. Please help me to understand, I will be needing it for the…
user2322960
29
votes
6 answers

What is the purpose of the Parity Flag on a CPU?

Some CPUs (notably x86 CPUs) feature a parity flag on their status register. This flag indicates whether the number of bits of the result of an operation is odd or even. What actual practical purpose does the parity flag serve in a programming…
Pharap
  • 3,826
  • 5
  • 37
  • 51
27
votes
6 answers

How to read and write x86 flags registers directly?

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…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
22
votes
2 answers

Assembly - Carry flag VS overflow flag

I have the next code: mov al, -5 add al, 132 add al, 1 As I check it, the overflow flag and the carry flag will set in the first operation, and in the second, only the overflow will set. But I don't understand why: In unsigned number, the result…
Tom O
  • 237
  • 1
  • 4
  • 7
14
votes
5 answers

check if carry flag is set

Using inline assembler [gcc, intel, c], how to check if the carry flag is set after an operation?
hans
  • 143
  • 1
  • 1
  • 4
12
votes
2 answers

How to determine when zero flag, sign flag, overflow flag and carry flag are set?

The whole flag thing is confusing the heck out of me. The definitions on the web seem really plain. I can't seem to get a really good applicable explanation to all this. According to their definitions, - carry: indicates an unsigned integer…
rose
  • 657
  • 2
  • 10
  • 20
11
votes
1 answer

Why does cmp 0x84,0x30 trigger the overflow flag?

I've been playing with assembly for a while and looking at some code. in which AL is first set to 0x84 then cmp AL, 0x30 is used. This instruction then triggers the Overflow flag. From what I read CMP is supposed to subtract the second number from…
Maciek
  • 261
  • 2
  • 11
9
votes
1 answer

x86 reserved EFLAGS bit 1 == 0: how can this happen?

I'm using the Win32 API to stop/start/inspect/change thread state. Generally works pretty well. Sometimes it fails, and I'm trying to track down the cause. I have one thread that is forcing context switches on other threads by: thread stop fetch…
Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
9
votes
2 answers

Direction Flag in x86

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?
user379888
7
votes
1 answer

Why doesn't bitwise NOT affect the ZF bit or any other FLAGS?

NOT on a register holding binary 11111111 will produce 00000000, but ZF will still have its old value, so it might not be 1 even though the output value is all zero. XOR reg, -1 would do the same thing but will set FLAGS according to the result. Why…
C7E
  • 73
  • 4
7
votes
2 answers

x86 register flag abbreviations

I'm currently studying assembly language. In Microsoft visual studio 2017, I wanted to check the current status of the register flags. I wanted to know what each register flag abbreviation stands for, so I checkout the wiki page on x86 register…
Thor
  • 9,638
  • 15
  • 62
  • 137
7
votes
3 answers

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

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?
Muhammadreza
  • 157
  • 2
  • 4
  • 9
7
votes
1 answer

How is the sign flag calculated with the imul instruction?

The documentation for imul states that: SF is updated according to the most significant bit of the operand-size-truncated result in the destination. For a 64-bit operation, then, my understanding is that SF = (a * b) >> 63, or more simply if a and…
zneak
  • 134,922
  • 42
  • 253
  • 328
6
votes
2 answers

x86 sbb with same register as first and second operand

I am analyzing a sequence of x86 instructions, and become confused with the following code: 135328495: sbb edx, edx 135328497: neg edx 135328499: test edx, edx 135328503: jz 0x810f31c I understand that sbb equals to des = des - (src + CF), in other…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
1
2 3 4 5 6 7