1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Carry and overflow flag

Tags:
  1. Feb 14, 2016 #1
    1. The problem statement, all variables and given/known data
    Find the carrry flag,overflow flag, set flag after these instructions
    A=68H -100
    B=-12+A
    C=B-33H
    D=C+53H
    2. Relevant equations


    3. The attempt at a solution
    I change the value to binary
    A
    68H--------->1101000
    100---------->1100100

    1101000
    - 1100100
    0000100


    B
    12---------->1100
    After 2s complement
    -12---------->11110100

    11110100
    + 00000100
    11111000

    C
    33H---------->110011

    11111000
    - 00110011
    11000101
    D
    53H---------->1010011

    11000101
    + 01010011
    101001000


    So the carry flag is 1 ,
    then 68H=104, 33H=51, 53H=83
    {[-12+(104-100)]-51}+83
    =24
    Since the sign bit is 1 ,it is overflow
    the overflow flag is 1
    But how to find Set flag?
     
  2. jcsd
  3. Feb 14, 2016 #2

    Hesch

    User Avatar
    Gold Member

    You must tell what is meant by "set flag".
    It depends on which programming language is used and/or which processor is used.
    E.g. as for an "ARM"-processor, the "set flag" is a flag included in an assembly instruction:

    ADD D0,D1,D2 means: D0 = D1+D2 without any set/reset of carry, sign, etc. ( set flag = 0 in the instruction)
    whereas
    ADDS D0,D1,D2 means: D0 = D1+D2 with set/reset of carry, sign, etc. ( set flag = 1 in the instruction)

    So, what is meant by "set flag"?
     
  4. Feb 15, 2016 #3
    I am not sure about the meaning but I am using assembly language for 8086.
     
  5. Feb 15, 2016 #4

    Hesch

    User Avatar
    Gold Member

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Carry and overflow flag
  1. Arithmetic Overflow (Replies: 3)

Loading...