JoderCoder 0 Newbie Poster

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.