A discussion of each line of the code is as follows: The first two lines declare the .data and the .text segments of our code. There is nothing after the .data segment because we have no variables to store. All of our instructions follow the .text segment. Next comes the declaration of the main: label in line 3 which is required for any code we wish to run. Lines 4-7 read in and store a value. To read a value we must make a system call (or syscall), and tell our processor we need input. Each syscall (there are many types) has an associated number. In order to make a syscall we put the call's associated number in $v0 and then execute the syscall instruction. In our case the associated number for reading in a numerical value is 5. Once a syscall finishes its return values are stored in $v0 and/or $v1. Lines 8-11 repeat the reading process but store the value in a different register. Line 12 calculates the sum of the two values we read in. Lines 13-16 handle printing out the computed sum. In this case we are using the print_int syscall whose number is 1. This syscall prints out whatever value is stored in the argument register $a0. Finally we must exit the main method. Lines 17 and 18 accomplish this by using the exit syscall. Question 1. Modify the above piece of code so it can add 3 numbers. Include your code in the report. Question 2. What modifications were needed to add the 3 numbers?
A discussion of each line of the code is as follows: The first two lines declare the .data and the .text segments of our code. There is nothing after the .data segment because we have no variables to store. All of our instructions follow the .text segment. Next comes the declaration of the main: label in line 3 which is required for any code we wish to run. Lines 4-7 read in and store a value. To read a value we must make a system call (or syscall), and tell our processor we need input. Each syscall (there are many types) has an associated number. In order to make a syscall we put the call's associated number in $v0 and then execute the syscall instruction. In our case the associated number for reading in a numerical value is 5. Once a syscall finishes its return values are stored in $v0 and/or $v1. Lines 8-11 repeat the reading process but store the value in a different register. Line 12 calculates the sum of the two values we read in. Lines 13-16 handle printing out the computed sum. In this case we are using the print_int syscall whose number is 1. This syscall prints out whatever value is stored in the argument register $a0. Finally we must exit the main method. Lines 17 and 18 accomplish this by using the exit syscall. Question 1. Modify the above piece of code so it can add 3 numbers. Include your code in the report. Question 2. What modifications were needed to add the 3 numbers?
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Fast
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY