Direction Flag
The direction flag is a CPU flag specific to Intel 80x86 processors. It applies to all assembly instructions that use the REP (repeat) prefix, such as MOVS, MOVSD, MOVSW, and others. Addresses provided to applicable instructions are increased if the direction flag is cleared.
Assembly languages have extra directives for assembling blocks of data, and assigning address locations for instructions or code.
TEST
The test instruction logically ands its two operands and sets the flags but does not save the result. Test and and share the same relationship as cmp and sub. Typically you would use this instruction to see if a bit contains one. Consider the following instruction:
test al
1
This instruction logically ands al with the value one. If bit zero of al contains a one the result is non-zero and the 80x86 clears the zero flag. If bit zero of al contains zero then the result is zero and the test operation sets the zero flag. You can test the zero flag after this instruction to decide whether al contained zero or one in bit zero.
The test instruction can also check to see if one or more bits in a register or memory location are non-zero. Consider the following instruction:
test dx
105h
This instruction logically ands dx with the value 105h. This will produce a non-zero result (and therefore clear the zero flag) if at least one of bits zero two or eight contain a one. They must all be zero to set the zero flag.
The test instruction sets the flags identically to the and instruction:
It clears the carry flag.
It clears the overflow flag.
It sets the zero flag if the result is zero they clear it otherwise.
It copies the H.O. bit of the result into the sign flag.
It sets the parity flag according to the parity (number of one bits) in the L.O. byte of the result.
It scrambles the auxiliary carry flag.
AND Logical AND between all bits of two operands. Result is stored in operand1.