In: Computer Science
Comment and show the result and how the flag register (CF, PF, SF, ZF) is affected after following
MOV AX, 39H MOV BL, 09H AND AL, BL
Comment and show the result and how the flag register (CF, PF, SF, ZF) is affected after following
MOV AX, 0708H MOV BX, 9A68HOR AX, BX
Comment and show the result and how the flag register (CF, PF, SF, ZF) is affected after following
MOV AX, 9A68H NOT AX
MOV and NOT instruction will not affect the carry, parity, zero and sign flag.
Parity flag is set when low order 8 bits have even 1's
Zero flag is set when all the bits of result is 0
Carry flag is set when an operation result will carry out
Sign flag is set when high order bit(MSB) of result is 1
1.
MOV AX, 39H -> It will store 39 in AX register, set AX = 39H means 0039 so AH = 00H and AL = 39H
MOV BL, 09H -> It will store 09 in BL register, set BL = 09H
Now, AND AL, BL -> It will perform and operation with 39 and 09
in binary 39 0011 1001
in binary 09 0000 1001
And operation between this two numbers = 0011 1001 & 0000 1001 = 0000 1001 = 09H
Here, no carry is set so CF = 0,As MSB is 0, SF will be 0, As value of accumulator is not 0 so, ZF = 0, parity flag will be 0
CF = 0, SF = 0, ZF = 0, PF = 0
2.
MOV AX, 0708H -> sets AX = 0708H
MOV BX, 9A68H -> sets BX = 9A68H
OR AX, BX
In binary 0708 -> 0000 0111 0000 1000
In binary 9A68 -> 1001 1010 0110 1000
Apply OR on this both,
0708 | 9A68 = 0000 0111 0000 1000 || 1001 1010 0110 1000 = 1001 1111 0110 1000 = 9F68H
Here, no carry is set so CF = 0, As MSB is 1, SF will be 1, As value of accumulator is not 0 so, ZF = 0, PF = 0
CF = 0, SF = 1, ZF = 0, PF = 0
3.
NOT instruction won't affect any flags
MOV AX, 9A68H --> sets AX = 9A68H
NOT AX
As AX = 9A68H. In binary, 9A68 = 1001 1010 0110 1000
So NOT AX = 0110 0101 1001 0111
Here, no carry is set so CF = 0, SF = 0, As value of accumulator is not 0 so, ZF = 0, PF = 0
CF = 0, SF = 0, ZF = 0, PF = 0