You are here: Articles > Programming > Programming

 See more articles about "Programming "

Assembly: Flags

 

The EFlags register, what they, what they do and when they are set.

The flags are located in a single 32-bit register (EFlags), each a single bit, thus holding a value of 1 true, or 0 false.



I will list the flags by name, location in the register and use:

*location will be a bit from 0-31

00: CF Carry Flag - becomes one if an addition, multiplication, AND, OR, etc results in a value larger than the register meant for the result

02: PF Parity Flag - becomes 1 if the lower 8-bits of an operation contains an even number of 1 bits

04: AF Auxiliary Flag - Set on a carry or borrow to the value of the loer order 4 bits

06: ZF Zero Flag - becomes 1 if an operation results in a 0 writeback, or 0 register

07: SF Sign Flag - is 1 if the value saved is negative, 0 for positive

08: TF Trap Flag - allows for the stopping of code within a segment (allows for single stepping/debugging in programming)

09: IF Interrupt Flag - when this flag is set, the processor begins 'listening' for external interupts

10: DF Direction Flag - determines the direction to move through the code (specific to repeat instructions)

11: OF Overflow Flag - becomes 1 if the operation is larger than available space to write (eg: addition which results in a number >32-bits)

12-13: IOPL I/O Privilage Level - Read, Write, or a combination of the 2 (2-bit register)

14: NT Nested Task - becomes 1 when calls within a program are made

16: RF Resume Flag - stays 1 upon a break, and stays that way until a given 'release' or resume opertaion/command occurs

17: VM Virtual Machine 8086 - becomes a 1 if the processor is to simulate the 8086 processor (16-bit)

18: AC Alignment Check - checks that a file or command is not breaking it's privilage level

19: VIF Virtual Interupt Flag - almost always set in protected mode, listening for internal and assmbling interupts

20: VIP Virtual Interupt Pending - 1 if a virtual interupt is yet to occur

21: ID ID Flag - is set if a CPU identification check is pending (used in some cases to ensure valid hardware)



*Missing bits are not mistakes, some flags temporarily use 2+ bits, and use neighbors to hold temporary values, also there are 17 necessary flags so 32-bits is the smallest register to hold them. (2^5)



NOTE: a single operation may change or set multiple flags, even those which seem independant may be nullified by specific operations.



The flags are used in many operations to save clock cycles and determine results without actually have to do read operations.

examples: jmp command (can be modified to a conditional jump, based on a flags value)



Questions/Comments: william_a_wilson@hotmail.com

-William. (marvin_gohan)

 

Also see ...

Assembly: Code Template
H3The general template for designing an Assembly code program/H3Pdiv class="code" br /TITLE    br /COMMENT br /        br / br /.MODEL SMALL br /.STACK 100H br /.DATA br / br /.CODE br /.486 br /INCLUDE io.mac br /main    PR

Assembly: If (MASM/TASM)
H3How to implement the in assembly, the effect of the if statement, which is available to other languages./H3PBeing that Assembly is a low level language, as opposed to the high level most programmers are used to (eg: Java, C, C++, Perl, etc), it doesn't have all the same features that these l

Assembly: mov statment (MASM/TASM)
H3How to use mov/H3Pmov is a useful tool in assembly language, it can move constants, or dynamics such as offsets. br / br /span style="font weight: bold"mov/span takes 2 parameters, the first is the reciever and the second is the operand. br / br /span style="font weight: bold"E

Assembly: constant jmp statment (MASM/TASM)
H3How to use jmp/H3Pjmp used as a jump statement jumps from one place to another: br / br /span style="font weight: bold"Example:/span br /div class="code" br /.MODEL SMALL br /.STACK 100H br /.DATA br /result_msg   DB  'true inside if statement',0 br /test

Assembly: conditional jmp statments (MASM/TASM)
H3How to use the conditional jmp, jumps (je, jg, jl, jne, etc)/H3Pa conditional jump, is just that, it jumps on a condition, if the condition is false, then if continues with the next line. br /eg: br / br /cmp 0,1 br /je one_equals_0 br /mov AX,0 br / br /if je ret