Link to home
Start Free TrialLog in
Avatar of bachra04
bachra04Flag for Canada

asked on

explanation required

I went through the following question / answer :

Assume that AX = BBBBh  and BX = BBBBh. What will be the contents
   of the AX register after the instruction:

      ADD AL,BL

   is executed.

   A. BBBBh    B. BBF6h   C. BB76h    D. BB78h    E. None of these

   Answer: C

   What will the condition code bits be after the instruction is
   executed.

   A. SF=0 ZF=0 OF=0 CF=1      B. SF=0 ZF=0 OF=1 CF=1

   C. SF=0 ZF=1 OF=0 CF=1      D. SF=1 ZF=0 OF=1 CF=1    E. None of the above

   Answer: B


I didn't understand why the OF is set to 1 can someone explain to me that ?

Thanks.
Avatar of Infinity08
Infinity08
Flag of Belgium image

>> I didn't understand why the OF is set to 1 can someone explain to me that ?

OF is the overflow flag, and it is set if the previous instruction caused an (arithmetic) overflow.

In this case, ADD AL,BL caused an overflow, so the flag is set.
Avatar of bachra04

ASKER

I understand that :

BBh + BBh caused a carry that's why CF is set ;

But what confuses me is when do we say that there is Overflow; do you mean every time we have a carry we'll have overflow ?
Is there a case when we have overflow and not a carry ? or vice versa ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can the carry flag be set 1 in a substraction operation :

e.g : sub 11h, 44h
>> Can the carry flag be set 1 in a substraction operation :

In the case of a subtraction, the CF is set in case of what is called a borrow :

        00000001 - 00000010 = 11111111

In order for this (unsigned) subtraction to work, we need a borrow, to add a 9th 1 bit to the first operand :

        100000001 - 00000010 = 11111111

so the CF flag is set.