Help me with this Assembly Language Code!!

Discussion in 'Homework Help' started by zero_coke, Nov 20, 2011.

  1. zero_coke

    Thread Starter Active Member

    Apr 22, 2009
    294
    1
    The question is attached, I need help to figure out what the hell this question is even asking us :(
     
    • q2.PNG
      q2.PNG
      File size:
      43.1 KB
      Views:
      60
  2. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    The question is very clear. Fill in the blank boxes. This should be moved to homework.
     
  3. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    You are required to run the program by hand and writing the contents of the Accumulator and the Stack at the same time.
     
  4. zero_coke

    Thread Starter Active Member

    Apr 22, 2009
    294
    1
    I get that but how do you do this lol
     
  5. nithish j

    New Member

    Nov 20, 2011
    1
    0
    it is simple right..first instruction pushes one to stack..then the added result is on top of stack.pop is not needed.tos is 4 now.lda loads a with 5.then with seven..push iot an muls multiplies 7 with three result is 21..popped to ac
     
  6. zero_coke

    Thread Starter Active Member

    Apr 22, 2009
    294
    1
    Thanks! Whenever an ADD/MULS is done, it says that top two stack elements are added/multiplied, does that mean the second-top element disappears or stays there??
     
  7. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    When multiplying two numbers in the stack, both numbers are popped from the stack, multiplied, and the result is pushed back onto the stack without touching the Accumulator, according to the description of the MULS instruction in the question.

    However, I'm not sure if this is the expected result, or if LDA is supposed to push onto the stack as well, it normally doesn't.

    [​IMG]

    Unless the question meant the stack was filled with 3s, or the LDA also pushed the value, which I doubt.
     
  8. zero_coke

    Thread Starter Active Member

    Apr 22, 2009
    294
    1
    Ok thanks!
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    Be careful. I think the stack begins at Stack Base. So the first value of 3 should be at location Stack Base. The first PUSH instruction would put the value 1 at Stack Base + 1.
     
  10. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I was wondering about those labels. The stack is labeled wrong for getting the intuitive concept across.

    I decided to go with "looks good". Teacher may disagree.
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    It depends which way the stack grows. It can grow towards lower addresses or higher addresses. This is just a pseudo computer as a teaching model.
     
  12. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Also, the Zero Flag in the non-existent status register would be set on the last two instructions, it's sometimes faster to check the zero flag than to compare to zero after an operation.
     
  13. zero_coke

    Thread Starter Active Member

    Apr 22, 2009
    294
    1
    Yeah the stack + 3 is the top of the stack, so stack base initially contains value 3. Also, ADD/MULS apparently does not delete the 2nd top element...it just takes result and overwrites top element (according to Professor for this problem only).
     
  14. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I was thinking in RPN, the best calculator OS around, from HP. Give a 35s a try!
     
Loading...