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

Program 4

This document outlines an assignment to create a MIPS assembly program that computes a floating point number raised to an integer power. It includes learning objectives, specific tasks to complete, and programming standards for documentation and code clarity. The assignment emphasizes input/output operations, algorithm development, and understanding floating point arithmetic in MIPS assembly.

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)
2 views

Program 4

This document outlines an assignment to create a MIPS assembly program that computes a floating point number raised to an integer power. It includes learning objectives, specific tasks to complete, and programming standards for documentation and code clarity. The assignment emphasizes input/output operations, algorithm development, and understanding floating point arithmetic in MIPS assembly.

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 4: Making procedures and using floating point arithmetic

in MIPS Assembly

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


a program that will repeatedly ask for a floating point number and an integer
and use a procedure to compute and display the floating point number raised
to the entered integer value.

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. use floating point operations and understand the problems with


floating point precision

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


gain experience in data representation and storage for data in the computer
and the impact of representing values using discrete, binary representations.
Recognize the difference in how processors manage and use floating point
versus integer values.

Specific Tasks:

Write and test a MIPS assembly language program to perform the following
actions in order:

1. Download the template.asm Download template.asmassembler


template for MIPS assembly programs

2. Print a welcome message that include: your name, a title, and a brief
description of the program.

3. Prompt the user to enter a floating point value

4. Prompt the user for an integer power for that floating point number

5. Use a procedure of your design to

1. Compute the floating point value raised to the entered value


2. Display the result of that operation

6. Repeat steps 3 through 5 as long as the user desires to continue

7. Print a farewell message and exit the program gracefully.

Your program should follow these loosely outlined steps in its implementation
(i.e., write the code for step 1, then for step2, etc.).

Enter the value 3.2 for the floating point value and -3 for the integer
exponent. Give a brief explanation of the results you obtain compared to the
results from a scientific calculator. Place this explanation in the comments at
the start of your program.

Assembly Language Programming Standards

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.

You will also need to include comments, whitespace, 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).

Programs that do not include sufficient internal documentation via comments


will receive deductions as indicated in the assignment rubric.

Sample Execution

Here is sample output from my solution program (your output may vary).
Submitting your program
You need to submit your complete assembly language program using
Canvas. The only file extension that is accepted is the ".asm" file created by
the MARS program.

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
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