Help me with this Assembly Language Code!!

Georacer

Joined Nov 25, 2009
5,182
You are required to run the program by hand and writing the contents of the Accumulator and the Stack at the same time.
 

nithish j

Joined Nov 20, 2011
1
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
 

Thread Starter

zero_coke

Joined Apr 22, 2009
294
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??
 

thatoneguy

Joined Feb 19, 2009
6,359
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.



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

Attachments

MrChips

Joined Oct 2, 2009
21,148
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.
 

thatoneguy

Joined Feb 19, 2009
6,359
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.
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.
 

MrChips

Joined Oct 2, 2009
21,148
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.
 

Thread Starter

zero_coke

Joined Apr 22, 2009
294
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).
 

thatoneguy

Joined Feb 19, 2009
6,359
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).
I was thinking in RPN, the best calculator OS around, from HP. Give a 35s a try!
 
Top