Question: Write a MIPS ASSEMBLY program that swaps any two records, and then prints the entire array. The program must ask the user to enter the
Write a MIPS ASSEMBLY program that swaps any two records, and then prints the entire array. The program must ask the user to enter the record numbers. Assume the record are numbered from 1 to 10. For example, if the user enters 4 and 7, then the program swaps the record 4 and the record 7.
- Each record consists of name of type string of up to 40 characters, age of type integer, and salary of type integer.
Here is how I stored the records (i have the code for printing and it works correctly)
main:
la $t0, Emp #load address of Emp
li $t1, 10 #counter for 10 records
readLoop:
blez $t1, print
la $a0, prompt1 #prompt asking for name
li $v0, 4 #print prompt
syscall
move $a0, $t0
li $a1, 40 #up to 40 char
li $v0, 8 #read name (string)
syscall
la $a0, prompt2 #prompt for age
li $v0, 4 #print prompt
syscall
li $v0, 5 #read age (int)
syscall
sw $v0, 40($t0)
la $a0, prompt3 #prompt for salary
li $v0, 4 #print prompt
syscall
li $v0, 5 #read salary (int)
syscall
sw $v0, 44($t0) #store into array
addi $t0, $t0, 48 #next record
addi $t1, $t1, -1 #counter -1
j readLoop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
