Only problem 2. Show work please. <3 Problem 2 (30 pts.): Using the stack Declar
ID: 3683165 • Letter: O
Question
Only problem 2. Show work please. <3
Problem 2 (30 pts.): Using the stack Declare the following four numbers in your data declaration directive (.data). num1 num3: word 34527, ·word 12953, num4: num2: word 98564 ·word 68577 · Write a program to reverse their order using the stack, and print out the numbers in that reverse order Assume stack pointer refer to last filled location. Remember to output a CR/LF each appears on a new line (use the code below for that) between each number so that li Sv0,11 li $a0 10 syscallExplanation / Answer
Push – sub $sp,$sp,4 (pointing to empty location),
sw $tx,($sp).
Pop– lw $tx,($sp) retrieves data,
addi $sp,$sp,4 “empties” memory.
Program:
Data
num1 DW 34527
num2 DW 98564
num3 DW 12953
num4 DW 68577
_start:
output:
68577
12953
98564
34527
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.