Please answer this question in MARIE language/instruction commands. Thank you.
Write a program to perform stack operations in MARIE language. The program has a data structure for the stack as follows:
PTR, Hex 0002 / Initialized to point to STACK
STACK, Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
Hex 0000 / Reserve for stack
A, Hex 0004 / Test variable
B, Hex 0006 / Test variable
C, Hex 0008 / Test variable
The program should perform the following tasks:
1) Write the subroutines push and pop for a stack.
2) The main program performs the push operations by calling the subroutine push: push the values of three variables A, B, and C into the stack in that order. Output (print) the value of each variable as the program pushes that variable into the stack.
3) The main program performs the pop operations by calling the subroutine pop: pop all three items from the stack. Output the value of each variable as it pops that variable from the stack.
In this example, the value of PTR is initialized to Hex 0002, which is the address corresponding to STACK. However, this address of PTR depends on the actual address of STACK in your program. Thus, you should manually compute this address and initialize PTR with this address. The remaining data structure should be the same as the structure listed above. That means the contents of the stack should be initialized to 0.