Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use MIPS assembly language to write this program Reading and Printing SPIM provides a small set of operating system-like services through the system call instruction,

image text in transcribed
image text in transcribeduse MIPS assembly language to write this program
Reading and Printing SPIM provides a small set of operating system-like services through the system call instruction, named syscall. To request a service, a program loads the system call code it can be found in MIPS System calls uploaded in the Useful Resources folder in Sakai) into register $v0 and arguments into register file registers $a0-$a3 (or $f12 for floating-point values). System calls that return values put their results in the register $v0 (or $f0 for floating-point results) [1] Reading and printing operations can be done with syscall. In order to become familiar with syscall, read the following example first. # Registers used : $to -used to hold the first number # $t1 - used to hold th@ second numb@r $t2 - used to hold the difference of the contents of $t1 and $to # Svo - syscall parameter and return value # $a0 - syscall argument text main: ## Get first number from the user, store it into $t0 li $v0, 5 syscal move $t0, $v0 # load syscall read-int into $v0 # make the syscall. # move the number read into $t0 ## Get second number from the user, put into $t1 l vo, 5 # load syscall read-int into $v0 syscall # make the syscall. move $t1, v0 # move the number read into register t1 In this example, the syscall instruction is first used to read input. The system code for this operation is 5. Then we use system code 1 to print this input. Notice that we also use code 10 to terminate the program

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

Step: 3

blur-text-image

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 M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions