The 8085 microprocessor includes five flip-flops,also called FLAGS,which are set of reset after an operation according to data conditions of the result in the accumulator and other registers. They are called Zero(Z);Carry(CY);Sign(S);Parity(P) and Auxiliary carry (AC) flags, and the most commonly used flags are ZERO,CARRY and SIGN. The 8085 microprocessor used this flags to test the data conditions.
This flags have critical importance in the decision making process in 8085 simulator. The conditions (Set or rest) of the flags are tested through software instruction. For example: the instruction JC ( Jump to Carry) is implemented to change the sequence of a program when the CY flag is set. A good understanding about this five flag is essential in writing assembly language programs. The overall description about this flags are :
S-Sign flag :
After the execution of Arithmetic and logical operations, if the bit D7 of the result ( usually in the accumulator ) is 1, the sign flag is set. This flag is used with signed numbers in a given byte, if D7 is 1 , the number will be viewed as a negative number , if it is 0 then the number will be considered as positive. In arithmetic operations signed numbers, bit D7 is reserved for indicating the sign , and the remaining seven bits are used to represented the magnitude of a number. However, unsigned numbers , even if bit D7 of a result is 1 and the flag is set , it does not mean the result is negative.
AC-Auxiliary Carry flag:
In arithmetic operation when a carry is generated by digit D3 and passed it to digit D4, the AC flag is set. This flag is used internally for BCD(Binary-Coded-Decimal) operations and is not available for the programmer to change the sequence of the program with a jump instruction.
P-Parity Flag:
After an arithmetic or logical operation, if the result has an even number of 1s, the flag is set. If it has an odd number of 1s the flag is reset.
CY-Carry flag:
If an arithmetic operation result in a carry, the carry flag is set ; otherwise it is rest. The carry flag also serves a borrow flag for subtraction.
No comments:
Post a Comment