Help required with query

Discussion in 'Assembly Language Programming (ALP) Forum' started by tigerdivision, Apr 26, 2007.

  1. tigerdivision

    tigerdivision New Member

    Joined:
    Apr 26, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Greetings everyone

    I am currently experiencing a problem when trying to figure out the contents of an Accumulator. My query is this:

    Locations 601 to 603 hold data i.e. decimal numbers as per below:
    601 30
    602 3
    603 9
    .

    Locations 740 to 744 hold instructions as per below:
    740 LDA 601
    741 ADD 602
    742 ADD 603
    743 STO 603
    744 HALT 000

    Immediately before the instructions are executed the Accumulator holds the value 5.

    What is the value held in the accumulator after the instruction at location 740 has been executed? Is it 30? Or is it 30 + 5 i.e. 35?

    After all the instructions have been executed I reasoned that the value at location 603 is 47. Is this coorect?

    Many thanks!
    P.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,374
    Likes Received:
    388
    Trophy Points:
    83
    Having such a title and having the thread in the introduction made me to move it into the Database section and then I thought its not database query but your query in Assembly language. Frame your question so that its easy to understand from the title itself
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    It is impossible to answer your question without having the definition of the instruction set. If "LDA 601" is an immediate mode instruction, the contents of the accumulator (assuming "LDA" means load the accumulator), then the contents will be 601. If it is a direct mode instruction, then the contents will be the contents of location 601. If it is an indirect mode instruction, the the contents will come from the location whose address is contained in 601.

    I see no reason why it would ever add 5 with instruction 740. Where the hell did you come up with that?

    If one presumes that the operations are direct mode, then:
    Code:
    740 LDA 601 == 30
    741 ADD 602 == 33
    742 ADD 603 == 42
    743 STO 603 == 42 overwrites the 9
    744 HALT 000
    
    You should definitely learn how to incorporate important information into your posts. You don't mention the processor type or anything that helps you get help.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice