Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i. Write a MIPS program that reads and stores an array of 10 records, each record consists of name of type string of up to

i. Write a MIPS program that reads and stores an array of 10 records, each record consists of name of type string of up to 40 characters, age of type integer, and salary of type integer.

ii. Write a program that prints the array of records of Part(i) in a readable format

iii. Write a program that swaps any adjacent records, and then prints the entire array. The program must ask the user to enter the record numbers to be swapped.

The following code illustrates how a record can be read, stored, and printed.

#The following reads two records Emp1 and Emp2, each record consists of two attributes

name and of type string of up to 40 characters and salary of type integer. and then

prints both records

.data

Emp1: .space 44

Emp2: .space 44

newline: .asciiz" "

.text

#read and store the name of the first record.

la $a0, Emp1

li $a1, 40

li $v0, 8

syscall

#reads and store the salary of the first record.

li $v0, 5

syscall

sw $v0, 40($a0)

#read and store the name of the second record.

la $a0, Emp2

li $a1, 40

li $v0, 8

syscall

#read and store the salary of the second record.

li $v0, 5

syscall

sw $v0, 40($a0)

# print the name of first record.

li $v0,4

la $a0, Emp1

syscall

#print the salary of the first record.

li $v0, 1

lw $t0, 40($a0)

move $a0, $t0

syscall

# start a new line

li $v0,4

la $a0, newline

syscall

# print the name of the second record.

li $v0,4

la $a0,Emp2

syscall

# print the salary of the second record.

li $v0, 1

lw $t0, 40($a0)

move $a0, $t0

syscall

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions