SPIM Programming - Computer Architecture and Operating Systems | ECE 3055, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Class: Computer Arch & Oper Sys; Subject: Electrical & Computer Engr; University: Georgia Institute of Technology-Main Campus; Term: Summer 2007;

Typology: Assignments

Pre 2010

Uploaded on 08/05/2009

koofers-user-8j0
koofers-user-8j0 🇺🇸

4

(1)

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Summer 2007 ECE 3055
Assignment 2
Due Date: 11:59 pm, Monday June 4th, 2007.
Part I: SPIM Programming
Purpose:
To understand and apply shift, masking, and logical operations and the MIPS 32
procedure calling conventions
Goal
You will write a SPIM program that performs arithmetic on packed byte values. Recall
that four byte values can be packed into one word. Using the .byte data directive store an
array of 64 byte values (pick your own values) in the data segment. Use the .word
directive if you like. If we are initializing the byte array to random values you can see
that it does not really matter whether we use the .byte or .word directives!
Compute a new byte array which we will designate as the output array. This array is also
packed into words. The values in this array denote the location of “edges” in the original
array. An element at index i in the original array is an edge if the difference between
element i and element i+1 is greater than a threshold value. For example consider the
sequence of element values as follows.
2 4 3 8 5 2 9 1 1.....
The edge values for a threshold of 4 will be
0 0 1 0 0 1 1 0.....
Your program should query the user for a threshold value and only accept values between
0-63. If the value falls outside this range, the user should be queried again.
Requirements
Your solution should have the following procedures and control structure.
1. Given an index and the start of the array, a procedure with label getval that returns
the thresholded value at that index.
2. Given an index, the start of the array, and a 32-bit register, a procedure with label
putval that writes the least significant byte to that location.
3. A procedure, thresh, for computing the thresholded (0/1) value given three
element values.
4. Your program iteratively calls getval which in turn calls thresh.
5. Write a procedure to print an array to the console. On completion print out both
the values of the input array and output array. This is the last operation in the
program.
pf3
pf4

Partial preview of the text

Download SPIM Programming - Computer Architecture and Operating Systems | ECE 3055 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Assignment 2

Due Date: 11:59 pm, Monday June 4th^ , 2007.

Part I: SPIM Programming

Purpose:

To understand and apply shift, masking, and logical operations and the MIPS 32 procedure calling conventions

Goal

You will write a SPIM program that performs arithmetic on packed byte values. Recall that four byte values can be packed into one word. Using the .byte data directive store an array of 64 byte values (pick your own values) in the data segment. Use the. word directive if you like. If we are initializing the byte array to random values you can see that it does not really matter whether we use the. byte or. word directives!

Compute a new byte array which we will designate as the output array. This array is also packed into words. The values in this array denote the location of “edges” in the original array. An element at index i in the original array is an edge if the difference between element i and element i+1 is greater than a threshold value. For example consider the sequence of element values as follows.

2 4 3 8 5 2 9 1 1.....

The edge values for a threshold of 4 will be

0 0 1 0 0 1 1 0.....

Your program should query the user for a threshold value and only accept values between 0-63. If the value falls outside this range, the user should be queried again.

Requirements

Your solution should have the following procedures and control structure.

  1. Given an index and the start of the array, a procedure with label getval that returns the thresholded value at that index.
  2. Given an index, the start of the array, and a 32-bit register, a procedure with label putval that writes the least significant byte to that location.
  3. A procedure, thresh , for computing the thresholded (0/1) value given three element values.
  4. Your program iteratively calls getval which in turn calls thresh.
  5. Write a procedure to print an array to the console. On completion print out both the values of the input array and output array. This is the last operation in the program.
  1. You are only permitted to use lw and sw instructions for accessing memory (no byte instructions).
  2. All procedures must follow the MIPS procedure call convention. The procedures must use at least one of the $s registers, which should be saved and restored to the stack. You can decide what size your stack frame should be. Ensure that the stack frame size is documented in the program comments.

Some overall points and suggestions:

  1. Assume the array numbers are positive.
  2. You can predefine the masks that you need in the data segment. Then you can simply load the mask into a register and use it immediately in a masking operation.
  3. Write your program one procedure at a time, testing them individually before trying to use them all together.

Submission

Email a text file (with a .s or .asm extension) the TA by 11:59 pm, Monday, June 4 th^ ,

Grading Guidelines

For your information here are the grading guidelines for the SPIM component of the assignment.

  • Program compiles without errors (and appears to address the problem) : 35pts
  • Program executes correctly: (additional) 40 points
  • Documentation and description of the program: 25 points o Have (commented) a program header with your name, class, and assignment. o Rule of thumb for comments: Someone who is not aware of the assignment can understand what the program is computing.

a. How much space is occupied in the data segment and text segment by the above program? b. What are the values of loop, Blank, and L2? c. Provide the hexadecimal encoding of the bne instruction.

Submission

Email a PDF file to the TA by 11:59 pm, Monday, June 4th^ , 2007. The PDF file can be a word file or a scanned PDF from handwritten solutions (please make sure it is legible). You can combine this in the same file as your SPIM submission.