Array Multiplication and Function Calls in Computer Architecture | CPSC 321, Lab Reports of Computer Science

Material Type: Lab; Subject: COMPUTER SCIENCE; University: Texas A&M University; Term: Unknown 1989;

Typology: Lab Reports

Pre 2010

Uploaded on 02/13/2009

koofers-user-r6d-1
koofers-user-r6d-1 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Architecture
CPSC 321, Fall Semester 2004
Lab Assignment #3
Due: One week after your lab session Complete by yourself.
1 Objective
This lab assignment will make you familiar with number conversions, such
as decimal to hexadecimal. A small matrix multiplication routine allows you
to become familiar with the equivalent of two-dimensional arrays in MIPS
assembly language. The third problem is designed to reinforce your under-
standing of these conventions.
2 Assignment
[Base conversion - 40 points] For this part of the assignment, you are
required to write a MIPS assembly program to convert an unsigned integer
uin base binto its base dequivalent.
The following are the tasks to complete this part:
1. Accept a base bas an input.
2. Accept an unsigned integer uin base b.
3. Accept a target base das an input.
4. Convert uinto its base dequivalent.
5. Display the base dnumber onto the console.
Example.
Input base: 12
Input number in base 12: 12ab85
Convert to base? 16
Base 16 equivalent: ...
Assume that all inputs are well-formed, i.e. all numbers are within their
legal ranges.
1
pf3

Partial preview of the text

Download Array Multiplication and Function Calls in Computer Architecture | CPSC 321 and more Lab Reports Computer Science in PDF only on Docsity!

Computer Architecture CPSC 321, Fall Semester 2004 Lab Assignment # Due: One week after your lab session – Complete by yourself.

1 Objective

This lab assignment will make you familiar with number conversions, such as decimal to hexadecimal. A small matrix multiplication routine allows you to become familiar with the equivalent of two-dimensional arrays in MIPS assembly language. The third problem is designed to reinforce your under- standing of these conventions.

2 Assignment

[Base conversion - 40 points] For this part of the assignment, you are required to write a MIPS assembly program to convert an unsigned integer u in base b into its base d equivalent.

The following are the tasks to complete this part:

  1. Accept a base b as an input.
  2. Accept an unsigned integer u in base b.
  3. Accept a target base d as an input.
  4. Convert u into its base d equivalent.
  5. Display the base d number onto the console.

Example.

Input base: 12 Input number in base 12: 12ab Convert to base? 16 Base 16 equivalent: ...

Assume that all inputs are well-formed, i.e. all numbers are within their legal ranges.

[Array Multiplication - 40 points] Write a MIPS assembly program to multiply two 3x3 matrices, A and B, and store the result into a matrix C.

Note: Memory for the matrices should be defined statically in the .data section of your code and the data should be stored in a row major format, i.e. the matrix (^) 

a 00 a 01 a 02 a 10 a 11 a 12 a 20 a 21 a 22

is stored as the sequence (a 00 , a 01 , a 02 , a 10 , a 11 , a 12 , a 20 , a 21 , a 22 ).

The following are the tasks to complete this part:

  1. Multiply the two matrices A and B, store the result in C.
  2. Display the product matrix C on the console. (Verify the result by working out the solution.)

[Function calls/register convention - 20 points] Implement the following C program fragment in MIPS assembly lan- guage, and run it on SPIM.

int S, A, B, C, D;

/* Function f(a, b, c, d) / int f( int a, int b, int c, int d ) { int S; S = sum(diff(a,b),diff(c,d)); /a - b + c - d;*/ return ( S ); }

/* sum fn */ int sum( int a, int b) { int s; s = a + b; return s; }

/* diff fn */ int diff( int a, int b)