60 likes | 184 Vues
This guide explores how different assembly language instructions impact the flags register within a processor. It specifically focuses on which instructions affect the flags, with examples including MOV, ADD, SUB, INC, DEC, and NEG. Through detailed examples, such as adding hexadecimal values and interpreting the resulting flags, we can understand the settings for Carry Flag (CF), Parity Flag (PF), Auxiliary Flag (AF), Zero Flag (ZF), and Sign Flag (SF). The examples provide clarity on the flag states based on arithmetic operations, crucial for effective low-level programming.
E N D
Processor executes instruction • Flags are affected • Some instructions do not affect while some do InstructionAffect Flags MOV/XCHG none ADD/SUB all INC/DEC all except CF NEG all
Example: Show how the flags register affected by the addition of 38H and 2FH Sol: MOV BH,38H ;BH=38H ADD BH,2FH;add 2F to BH, now BH=67H CF = 0 since there is no carry beyond d7 PF = 0 since there is an odd number of 1s in the result AF = 1 since there is a carry from d3 to d4 ZF = 0 since the result is not zero SF = 0 since d7 of the result is zero 0011 1000 + 0010 1111 0110 0111
Sol 1001 1100 + 0110 0100 0000 0000 CF = 1 since there is a carry beyond d7 PF = 1 since there is an even number of 1s in the result AF = 1 since there is a carry from d3 to d4 ZF = 1 since the result is zero SF = 0 since d7 of the result is zero
Example • Show how the flags register affected by MOV AX,34F5H ADD AX,95EBH • Show how the flags register affected by MOV BX,AAAAH ADD BX,5556H (You need to solve both as an assignment)