v3_Registers_and_Flags_of_80x86_Architecture.pdf
💡Recall
- How many EU general registers are there?
🖋 Notes
Registers
- storage capacities
- very small in size (8, 16, 32, 64, 128)
- very very fast in terms of access speed used for temporary storage for the info with which a processor works currently
The EU general registers
EAX
accumulator register
- used by the most of instructions as one of their operands
EBX
ECX
counter register
- mostly used as numerical upper limit for instructions that need repetitive runs
EDX
data register
- frequently used with EAX when the result exceed a doubleword (32 bits)
ESP and EBP
stack registers (LIFO memory area)
ESP (Stack Pointer)
points to the last element put on the stack (the element from the top of the stack)
EBP (Base pointer)
points to the first element put on the stack (points to the stack’s basis)
EDI and ESI (Index Registers)
- usually
used for accessing elements from bytes and words strings
EAX, EBX, ECX, EDX, ESP, EBP, EDI, ESI
- (32 bits) doubleword registers = concatenation of 2 16 bits subregisters
AX, BX, CX, DX, SP, BP, DI, SI
- (18 bits) word registers
- AX, BX, CX and DX are a concatenation of two 8 bits subregisters
- upper register
- doesn’t have a name
- it isn’t available separately
- contains the most significant 16 bits of the 32 bits register
- AH, BH, CH, DH registers which contain the most significant 8 bits of the word (the upper part of AX, BX, CX and DX registers)
- lower register
- used as single
- AL, BL, CL, DL registers which contain the least significant 8 bits of the word (the lower part of AX, BX, CX and DX registers)
Flags
- an indicator
- represented on 1 bit
- a configuration of the FLAGS register shows a synthetic overview of the execution of the each instruction (what happens)
- for x86 the EFLAGS register (the status register) has 32 bits but only 9 are actually used
- 9 registers:
OF, DF, IF, TF, SF, ZF, AF, PF, CF

CF (Carry Flag)
-
transport flag, from the transport digit
-
referring to additions and subtractions ONLY
-
signals overflow for the case of UNSIGNED interpretation
-
1 if in the LPO there was a transport digit outside the representation domain of the obtained result
-
0 otherwise

PF (Parity Flag)
- in transmissions
- takes the least significant byte and check how many 1 digits do I have
1 if in the least significant byte of the representation of the LPO’s result we have an odd number of 1 digits
0 otherwise
AF (Auxiliary Flag)
- shows the transport value from bit 3 to bit 4 of the LPO’s result
1 or 0

ZF (Zero Flag)
1 if the result of the LPO was zero
0 otherwise
SF (Sign Flag)
1 if the result of the LPO is a strictly negative number
0 otherwise
TF (Trap Flag) (Debugging Flag)
if 1, then the machine stops after every instruction
IF (Interrupt Flag)
if 1 interrupts are allowed
if 0 interrupts will not be handled
DF (Direction Flag)
- for operating string instructions
if 1 string parsing descending order
if 0 string parsing ascending order (from the beginning to its end)
OF (Overflow Flag)
- signs an overflow
- referring to additions and subtractions ONLY
- signals overflow for the case of SIGNED interpretation
1 if the result of the LPO (considered in the signed interpretation) didn’t fit the reserved space (admissible representation interval)
0 otherwise
Flags categories
The flags can be split into 2 categories with:
-
previous effect generated by the Last Performed Operation (LPO):
CF, PF, AF, ZF, SF and OF
-
future effect after their setting by the programer, to influence the way the next instructions are run:
Specific instructions to set the flags values
Considering the 2nd category, it is normal that the assembly language to provide specific instructions to set the values of the flags that will have a future effect. So, we have 7 such instructions:
- CLC
- STC
- CMC
- CLD
- STD
- CLI
- STI
Given the major risk of accidentally setting the value from TF and also its absolutely special role to develop debuggers, there are NO instructions to directly access the value of TF !!