954,479 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Machine code for a program using stack

Firstly, this is not directly assembly question but quite close, it is machine code.

I am asked to add two numbers using stack. The question was actually asking for

1. write a program that adds the numbers 2 and 9 together. The number 2 is stored in memory-address 300 and 9 is stored in memory-address 301. The result should be stored in memory-address 307.

I have written this, some thing like this:

1300
5301
2307

2. Perform the same task as above, but this time using the stack. Use stack operands (PUSH, POP, etc) presented in Section 3 (slide 8). The initial memory locations are the same and the result should be stored in memory-address 307.

So 2nd one is the tricky part for me. Although I get the idea of stack operations, I am not sure how to write this program... I know I should use x8 (1000) for push and x9 (1001) for pop and I dont specify the address in the instruction for stack operations but I am still unsure how exactly do I write this program?

Any help, pointers?

JoderCoder
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You