Assembly Language Question

Discussion in 'Programmer's Corner' started by Jack912, May 27, 2013.

  1. Jack912

    Thread Starter New Member

    May 12, 2013
    3
    0
    Accumulator's content is 4AH, what will be the content of the flags (S,Z,AC,P and CY) after the addition of 59H? The instruction is ADI 59H .Could somebody explain on it ?quite confused on this part..:confused:
     
  2. piratepaul

    Member

    May 20, 2013
    35
    2
    No idea... I use batt's a lot...

    4Ah = 4 amphours

    ccA = cold cranking amps.

    Don't know if it is lead/acid ... sealed, high maintinence, high/low discharge, nicad or, or, or.
    Or I could tell you a bit more.
     
    absf and Markd77 like this.
  3. evilclem

    Member

    Dec 20, 2011
    118
    16
    Hi Jack,

    If you could tell us what chip you are writing this for, it would help.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,163
    1,796
    I vote for the 8085.

    S is the "sign" flag, which is set according to the the sign of the result
    Z is the "zero" flag which is set if the result of an operation is 0
    AC is th Auxiliary Carry which is set if there is a carry from bit 3. Used in BCD arithmetic
    P is the Parity bit and is set to the Parity of the result, but I forget which way it goes.
    CY is the Carry flag and is set to the carry out of the mos significant bit.

    So using Hexadecimal arithmetic you add 04AH to 059H and you get 0??H
    Since the result is NOT 000H the Z flag will not be set it will be cleared.
    Now you just figure out what happens to the rest.
     
    absf and Jack912 like this.
  5. Jack912

    Thread Starter New Member

    May 12, 2013
    3
    0
    s=1 as D7 is 1 ; z=0, AC=0 as D3 is 0 ; p=0 as even parity ;cy =0 as no carry .Are they correct ? Not sure whether S and AC are correct....
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,163
    1,796
    I think AC should be a 1 since there is a carry from the low nibble to the high nibble.

    00AH + 009H = 013H

    That's a 3 with an Aux Carry of 1

    D3 of the result is indeed 0, but it is not relevant to AC, It is the Carry from bit 3 of the addition.
     
  7. Jack912

    Thread Starter New Member

    May 12, 2013
    3
    0
    What is nibble? For this case how is it there is a carry from the low nibble to the high nibble? Could u explain it further ..
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
  9. Papabravo

    Expert

    Feb 24, 2006
    10,163
    1,796
    I thought I did explain it. The least significant digits are 00AH and 009H. When you add them together you get 013H which cannot fit in four bits so you say

    "0AH plus 09H is 013H, bring down the 3 and carry the one." How do you do addition in your head? I always talk to myself when I do it.
     
Loading...