0% found this document useful (0 votes)
4 views

Program 6

The document outlines an assignment to create a MIPS Assembly program that implements a linked list for entering and displaying individuals' names and ages. It specifies learning objectives, tasks to be performed, and programming standards, emphasizing the importance of comments and internal documentation. The document also includes sample execution output and details on system calls and MIPS commands needed for the assignment.

Uploaded by

i200745
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Program 6

The document outlines an assignment to create a MIPS Assembly program that implements a linked list for entering and displaying individuals' names and ages. It specifies learning objectives, tasks to be performed, and programming standards, emphasizing the importance of comments and internal documentation. The document also includes sample execution output and details on system calls and MIPS commands needed for the assignment.

Uploaded by

i200745
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Program: Linked lists and data structures in MIPS Assembly

Purpose: This assignment is designed to give you the opportunity to create


a program that will repeatedly allow you to enter the name and age of an
individual, list the names and ages of all the people entered so far, and exit
the program. The primary goal is to implement an linked list using the
assembly language instructions available.

Learning Objectives: You should be able to perform the following activities


at the end of this assignment:

1. perform input and output operations from the keyboard and to the
screen

2. write an algorithm in pseudocode

3. translate the algorithm from pseudocode into MIPS assembly

4. create procedures and pass parameters in MIPS assembly

5. allocate and manage access to memory in the Heap area of memory

6. General Knowledge: In addition to the specific skills learned, you


should gain experience in using pointers to access data and the impact
of allocating and managing dynamic memory.
7. Specific Tasks:
8. Write and test a MIPS assembly language program to perform the
following actions in order:
9. Print a welcome message that include: your name, a title, and a brief
description of the program.
10. Display a menu to
1. print the linked list
2. add a user
3. exit the program
4. prompt the user to enter a their choice and read that choice in
11. Based on the user choice use a procedures to perform the
following actions:
1. Display all the elements in the list or display a message that it is
empty
2. Add a user to the linked list. Each user entry will contain:
1. A name of up to 40 characters (39 usable, remove any
newlines)
2. An integer for the named individual,
3. A pointer to the next entry.
12. Repeat steps 3 and 4 as long as the user desires to continue
13. Print a farewell message and exit the program gracefully.
14. Your program should follow these loosely outlined steps in its
implementation (i.e., write the code for step 1, then for step2, etc.).
15. Assembly Language Programming Standards
16. Comments are vital in assembly language programming. You
will need to include a header similar to the one included in the MIPS
Assembly template Download MIPS Assembly template. In particular
the Pseudocode section and the register information will help you
solidify your understanding of the program requirements and your
method of solution.

17. You will also need to include comments, white space, and blank
lines in your code to make it easy to read and to follow the
implementation of the pseudocode. While one comment per line is not
required, you are encouraged to include enough comments in you code
to allow easy tracing of the pseudocode logic through your assembly
implementation (see the Fibonacci example provided on Canvas).
18. Programs that do not include sufficient internal documentation
via comments will receive deductions as indicated in the assignment
rubric.
19. Sample Execution
20. Here is sample output from my solution program (your output
may vary).
21. CS 2810: Dynamic Memory Allocation - Linked List - Waldo Wildcat

Add a person, print the linked list, or exit

Please select one of the following:


1} Print list
2} Add person
3) Exit

Choice? 1

The list is empty, nothing to print.

Please select one of the following:


1} Print list
2} Add person
3) Exit

Choice? 2

Please enter a name (up to 40 characters): Harry Potter


Please enter the age for Harry Potter: 11

Please select one of the following:


1} Print list
2} Add person
3) Exit

Choice? 2

Please enter a name (up to 40 characters): Albus Dumbledore


Please enter the age for Albus Dumbledore: 75

Please select one of the following:


1} Print list
2} Add person
3) Exit

Choice? 2

Please enter a name (up to 40 characters): Severus Snape


Please enter the age for Severus Snape: 38

Please select one of the following:


1} Print list
2} Add person
3) Exit

Choice? 1

-------- List Contents ----------


Name: Harry Potter Age: 11
Name: Albus Dumbledore Age: 75
Name: Severus Snape Age: 38

Please select one of the following:


1} Print list
2} Add person
3) Exit

Choice? 3

Additional Information:

As shown in class, there are several system calls that are available for use in
the MIPS assembly language. These system calls must be used for input and
output in your programs.

To perform a system call:

1. Load the service code in the $v0 register

2. Load any required argument values in $a0, $a1, $a2, or $f12 if the
system call requires them

3. Issue the syscall instruction


4. Use the returned values, if any, from the registers designated in the
command description

Example:

li $v0, 4 # service 4 is print string


la $a0, prompt # load address of string in $a0
syscall # initiate the system call to print the string

Available system calls and codes

syscall name Code in Arguments


$v0

print integer 1 $a0 = integer to print

print float 2 $f12 = float to print

print double 3 $f12 = double to print

print string 4 $a0 = address of null-terminated string


print

read integer 5

read float 6

read double 7

read string 8 $a0 = address of input buffer


$a1 = maximum number of characters t
read

sbrk (allocate 9 $a0 = number of bytes to allocate


heap memory)

exit (terminate 10
execution)

read a character 12

MIPS Assembly commands you may need for this assignment:

Arithmetic and Logical:

 add rd, rs, rt Addition with overflow rd = rs + rt


 sub rd, rs, rt Subtraction with overflow rd = rs - rt

 mul rd, rs, rt Multiply without overflow High|Low = rs


x rt and
rd = Low (low order 32-bits of result

 div rs, rt Divide w/out overflow High = remainder


(rs/rt)
Low = quotient (rs/rt) (must test for rt
== 0)

 and rd, rs, rt Perform a bitwise AND rd = rs AND rt

 or rd, rs, rt Perform a bitwise OR rd = rs OR rt

 mul.s rd, rs, rt Perform single precision multiply rd = rs *


rt

 div.s rd, rs, rt Perform single precision divide rd = rs /


rt

Memory Access:

 lw rd, offset(rs) Load word from memory rd = word at [rs


+ offset]
must load address in rs first

 sw rd, offset(rs) Store word into memory word at [rs +


offset] = rd
must load address in rs first

 move rd, rs Move contents of rs into rd rd = rs

 sb rt, offset(rs) Move contents of rt into byte at [rs +


offset]

 lbu rt, offset(rs) Move byte at [rs + offset] into rt, extended
by zeros

 mov.s rd, rs Move single precision rs into rd rd = rs

Other commands:

 syscall Execute the system call identified by $v0 (see


above)
 la rd, label Load the address of label into rd rd = address
of label

 li rd immd Load the numeric value immd into rd rd =


immd

 slt rd, rs, rtb If rs < rt, then rd is set to one

 blt rs, rt, label Branch if less than, if rs < rt, set program
counter to label

 beqz rs, label Branch if equal zero, if rs == 0, set PC to label

 jal label Jump and link, store return address in $ra and
jump to label

 jr rd Jump to address in register rd

You might also like