lab03
.docx
keyboard_arrow_up
School
University of California, Berkeley *
*We aren’t endorsed by this school
Course
MISC
Subject
Computer Science
Date
Feb 20, 2024
Type
docx
Pages
7
Uploaded by CaptainThunderGoldfish14
Kettering University
Computer Architecture and Organization
Lab Exercise 3
Design of MIPS Programs
Nested Procedures
Winter 2023
Note
Tests/final may contain questions about lab exercises.
Prelab
: Go over the handout rigorously.
Lab Report:
Upload one handout (report) per group (in .pdf
) to Blackboard before
11:59 pm on the coming
Sunday
and after
you have done all the assignments,
answered all the questions, and shown your lab work to the lab instructor individually
.
A demo sign-up sheet will be posted if necessary.
Name
: Lab Partner’s Name
: Purpose of this lab exercise (please use your own words)
CE-422/622 Lab Exercise 3
Objectives
Examine how MIPS supports nested procedures. More specifically,
How called and caller programs may communicate with each other.
How to jump to a procedure and save the return address.
How to use a stack.
How/when to save/restore registers.
How to return to the calling program.
Introduction
You will implement nested procedures
in the MIPS assembly language: The system program uses the {
jal
main
} instruction to call your first-level main program. Your main program then calls procedure xcount,
and procedure xcount
calls procedure xfind
, as explained in this handout.
What to hand in
Upload this handout in the .pdf format
after completing all the assignments and answering all the
questions.
Show your functional nested procedures in Assignment 2.
to the lab instructor.
Also, be prepared to individually
answer the lab instructor’s questions rearguing today’s lab exercise
and what your group did.
You should work closely with your lab partner. You are also urged to talk to other students, teach them, or learn from them, as this will enhance your performance; however, do NOT copy from them!
Please note:
We can enter a procedure ONLY with a jal
instruction.
We can exit a producer ONLY with a jr
instruction.
Otherwise, it would be a MAJOR mistake. Students making these mistakes
will not get credit for this lab. Page 2 of 7
CE-422/622 Lab Exercise 3
Assignments Create a lab03
folder in your Architecture
directory. Then make a text file called nested.txt in
lab03
. Place all three codes to be created today in nested.txt
.
1. Procedure xfind
Write procedure xfind
in MIPS assembly language that takes two arguments, $a0
and $a1
. Register $a0
is
a pointer to (the base of) a null-terminated ASCII character string, and $a1
has an ASCII character in its
least significant byte. The other three bytes of $a1
are reset to zero. xfind should locate the first matching
character in the string, return its address in $v0
, and return the character itself in $v1
. If the search is
unsuccessful,
xfind should return a pointer (
$v0
) to the null character and reset register $v1
. Use the
following main
program to test your xfind
. Place both codes in the same file and call it nested.txt
.
Note
: If you copy and paste a .doc
program into your text
file (source code), delete all the single and
double quotes (‘ ’ “ ”), if any, and type them again.
.
data
string
:
.
asciiz “This is a null-terminated ascii string.”
.
text
main
:
addi $sp, $sp, -4
# update $sp and then sw $ra, ($sp)
# push $ra (return address to system Prog.); this is the first push on the
stack
la $a0, string # $a0 becomes a pointer to the base of string li $a1, ’i’ # look for ‘i’. ‘i’ sits in LSByte of $a1, the other 3 bytes are reset to zero.
jal xfind
# call xfind
lw $ra, 0($sp) # pop $ra ($ra becomes return address to system program)
addi $sp, $sp, 4
# restore $sp
return
:
jr $ra # return to system program
Once you have tested your xfind
successfully, copy your commented and
indented
xfind
to the space
reserved for Figure 3.. 2. Procedure xcount
Before you proceed with this section, test your
xfind
and make sure it works. Write procedure xcount
in MIPS assembly language that takes two arguments, $a0
and $a1.
Register $a0
is a pointer to (the base of) a null-terminated ASCII character string, and $a1
has an ASCII character in
its least significant byte; the other three bytes of $a1
are cleared. This procedure should return in $v0
the
total number of instances of the matching character in the string. You should use your xfind
in your
xcount
. Add xcount
to file nested.txt
. To test the whole system, use the same main code you already
have in nested.txt
(and used in Assignment 1.)
after you replace jal xfind
with
jal xcount
. Figure 1. shows
the communication between the caller/callee pairs graphically. What is the best place to put a
breakpoint when you use the RUN command (F5)? Note that xcount
is a non-leaf procedure; therefore, you need to save the return address (
$ra
) before xfind
is called; otherwise, the return address to the main program will be lost. Also, use $s0 as the “hit-counter”
in xcount
. So, you need to save $s0 as well. These registers must be restored when xcount
ends and
before it returns to its calling (
main
) program. Page 3 of 7
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Income statement and balance sheet columns on a worksheet should balance when they are first
added up.
arrow_forward
write access model Only Leena can access her laptop. The website can be accessed only during work time The file is a read-only file. Only course instructors can access students' data.
arrow_forward
Project name: Errand Assistance service application(ease app)
Create the Data Flow Diagram and Data Dictionaries of your project.
arrow_forward
Project Description
A telephone book system, also known as a telephone directory, telephone address book, or Phone book, is a listing of telephone subscribers in a geographical area or subscribers to services provided by the organization that publishes the directory. Its purpose is to allow the telephone number of a subscriber identified by name and address to be found.
Project Features
The features of telephone book system are mainly related to adding, listing, searching, sorting, modifying and deleting telephone directory-related records. All these operations are done through Linked-List.
The information contained in the telephone directory records are the first name, last name, phone number, city, address, sex and email of the person whose record is entered in the telephone directory system.
Project Operations
Write a JAVA program that will maintain a phone directory using a Linked-List. The program should be able to perform the following operations:
Add persons details (first…
arrow_forward
List 10-15 application that you have encountered or know.
arrow_forward
true/false
Both professor and assistant can create a new course (use case Create course) ( )
arrow_forward
Q: Explain the document downloading task card please.
arrow_forward
Briefly explain your technique's for exam preparation.
arrow_forward
What method do you use to analyze the information?
arrow_forward
DATABASE SYSTEMS:
QUESTION
Do as directed
This describes the business process to publish an academic paper. The author submits a paper to an editor in chief of a journal. The editor first checks whether the paper fit the theme of the journal. If not, the editor rejects the paper. Otherwise, the editor in chief assigns the paper to a number of reviewers. The reviewers review the paper, and write a review. The review is sent to the editor in chief. The editor in chief then assesses the quality of the paper with the help of reviewers’ comments. If the quality is good, the paper will be accepted, and the author notified. Furthermore, the paper is forwarded to the publisher for publication. If the quality is bad, the editor rejects the paper.
Apply query to only access to compile the final decision to editor in chief and only visualized by author not reviewers
arrow_forward
Explain the importance of using cell references rather than constant values when creating formulas in a spreadsheet.
arrow_forward
What is the analysis of result?
arrow_forward
Differentiate primary, candidate, and superkey.
arrow_forward
Briefly describe the procedure.
arrow_forward
Differentiate between Collection and Collections
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Enhanced Discovering Computers 2017 (Shelly Cashm...
Computer Science
ISBN:9781305657458
Author:Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Publisher:Cengage Learning
Related Questions
- Income statement and balance sheet columns on a worksheet should balance when they are first added up.arrow_forwardwrite access model Only Leena can access her laptop. The website can be accessed only during work time The file is a read-only file. Only course instructors can access students' data.arrow_forwardProject name: Errand Assistance service application(ease app) Create the Data Flow Diagram and Data Dictionaries of your project.arrow_forward
- Project Description A telephone book system, also known as a telephone directory, telephone address book, or Phone book, is a listing of telephone subscribers in a geographical area or subscribers to services provided by the organization that publishes the directory. Its purpose is to allow the telephone number of a subscriber identified by name and address to be found. Project Features The features of telephone book system are mainly related to adding, listing, searching, sorting, modifying and deleting telephone directory-related records. All these operations are done through Linked-List. The information contained in the telephone directory records are the first name, last name, phone number, city, address, sex and email of the person whose record is entered in the telephone directory system. Project Operations Write a JAVA program that will maintain a phone directory using a Linked-List. The program should be able to perform the following operations: Add persons details (first…arrow_forwardList 10-15 application that you have encountered or know.arrow_forwardtrue/false Both professor and assistant can create a new course (use case Create course) ( )arrow_forward
- DATABASE SYSTEMS: QUESTION Do as directed This describes the business process to publish an academic paper. The author submits a paper to an editor in chief of a journal. The editor first checks whether the paper fit the theme of the journal. If not, the editor rejects the paper. Otherwise, the editor in chief assigns the paper to a number of reviewers. The reviewers review the paper, and write a review. The review is sent to the editor in chief. The editor in chief then assesses the quality of the paper with the help of reviewers’ comments. If the quality is good, the paper will be accepted, and the author notified. Furthermore, the paper is forwarded to the publisher for publication. If the quality is bad, the editor rejects the paper. Apply query to only access to compile the final decision to editor in chief and only visualized by author not reviewersarrow_forwardExplain the importance of using cell references rather than constant values when creating formulas in a spreadsheet.arrow_forwardWhat is the analysis of result?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageEnhanced Discovering Computers 2017 (Shelly Cashm...Computer ScienceISBN:9781305657458Author:Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. CampbellPublisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Enhanced Discovering Computers 2017 (Shelly Cashm...
Computer Science
ISBN:9781305657458
Author:Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Publisher:Cengage Learning