1. Homepage
  2. Programming
  3. CSI404 Assignment 1: Translate C to MIPS assembly

CSI404 Assignment 1: Translate C to MIPS assembly

Engage in a Conversation
AlbanyCSI404ECE404Computer Architecture and OrganizationMIPSCAssembly

Objective CourseNana.COM

To learn the fundamentals of MIPS architecture through the use of its assembly language and the SPIM simulator. CourseNana.COM

Description CourseNana.COM

You are to write a complete program in MIPS assembly language that behaves exactly as the included C program. This program contains four functions in addition to the main() one. Your solution must contain all five C routines as they have been coded in the example. In essence, your solution must follow their dependence as determined by the way they are invoked in the C code included. You are to use the MIPS simulator QtSpim. A list of SPIM system calls is provided in the lecture notes and also supplied below for quick reference: CourseNana.COM

Service CourseNana.COM

print_int print_float print_double print_string read_int read_float read_double read_string sbrk CourseNana.COM

System Call Code CourseNana.COM

1 2 3 4 5 6 7 8 9 10 CourseNana.COM

Arguments CourseNana.COM

$a0 = integer $f12 = float $f12 = double $a0 = string CourseNana.COM

$a0 = buffer, $a1 = length $a0 = amount CourseNana.COM

$a0 = character CourseNana.COM

$a0 = filename,
$a1 = flags, $a2 = mode CourseNana.COM

Result CourseNana.COM

integer (in $v0) float (in $f0) double (in $f0) CourseNana.COM

address (in $v0) CourseNana.COM

character (in $v0)
file descriptor (in
$v0) CourseNana.COM

exit
print_character 11 read_character 12 open 13
CourseNana.COM

read write CourseNana.COM

close exit2 CourseNana.COM

14 $a0 = file descriptor,
$a1 = buffer, $a2 = count CourseNana.COM

15 $a0 = file descriptor,
$a1 = buffer, $a2 = count CourseNana.COM

16 $a0 = file descriptor 17 $a0 = value CourseNana.COM

bytes read (in $v0) bytes written (in $v0) 0 (in $v0) CourseNana.COM

Both the function call and return must be done by the pair jal function-name and jr $ra of MIPS instructions. The program that follows illustrates this requirement where the function hello is invoked by a jal hello call in the main function. The jr $ra instruction in function hello illustrates how this function returns execution to the main function. CourseNana.COM

.data
str: .asciiz "Hello Word!.\n"
CourseNana.COM

.text
.globl main #necessary for the assembler
CourseNana.COM

main: hello: CourseNana.COM

jal hello
li $v0,10
syscall #exit the program gracefully. la $a0, str
li $v0,4
syscall # to print.
jr $ra
CourseNana.COM

Grading scheme CourseNana.COM

The following is a tentative grading scheme. CourseNana.COM

1. Source Code.
a. [10%] Programming style.
CourseNana.COM

  1. [5%] Layering. CourseNana.COM

  2. [3%] Readability. CourseNana.COM

  3. [2%] Comments. CourseNana.COM

b. [90% total] Correctness.
The five functions will be graded according to the percentages stated in the table below.
CourseNana.COM

Function implemented % CourseNana.COM

getMax countSort radixSort printData main CourseNana.COM

What to Submit CourseNana.COM

20 30 20 10 10 CourseNana.COM

The following are to be submitted to your co-instructor: CourseNana.COM

  1. Copies of all .asm files you created for this exercise as well as CourseNana.COM

  2. Screenshots of the results produced by your solution. CourseNana.COM

All above listed information must be placed in a Microsoft compressed (zipped) folder (.zip). Your .zip folder must be named: 404 Programming Assignment 1- Your Name. Marks will be deducted if you do not follow this requirement. CourseNana.COM

CourseNana.COM

#include <stdio.h> CourseNana.COM

int getMax(int arr[], int n) { CourseNana.COM

int mx = arr[0];
for (int i = 1; i < n; i++)
CourseNana.COM

if (arr[i] > mx) mx = arr[i]; CourseNana.COM

return mx; } CourseNana.COM

void countSort(int arr[], int n, int exp) { CourseNana.COM

int output[n];
int i, count[10] = { 0 };
CourseNana.COM

for (i = 0; i < n; i++) count[(arr[i] / exp) % 10]++; CourseNana.COM

for (i = 1; i < 10; i++) count[i] += count[i - 1]; CourseNana.COM

for (i = n - 1; i >= 0; i--) {
output[count[(arr[i] / exp) % 10] - 1] = arr[i]; count[(arr[i] / exp) % 10]--;
CourseNana.COM

} CourseNana.COM

for (i = 0; i < n; i++) arr[i] = output[i]; CourseNana.COM

} CourseNana.COM

void radixSort(int arr[], int n) { CourseNana.COM

int m = getMax(arr, n);
for (int exp = 1; m / exp > 0; exp *= 10)
CourseNana.COM

countSort(arr, n, exp); } CourseNana.COM

void printData(int arr[], int start, int len) { CourseNana.COM

if( start >= len ) return( 0 ); CourseNana.COM

printf("%d \n", arr[start]); CourseNana.COM

printData(arr, start+1, len); } CourseNana.COM

int main() { CourseNana.COM

int arr[] = {7, 9, 4, 3, 8, 1, 6, 2, 5}; int n = sizeof(arr) / sizeof(arr[0]); CourseNana.COM

radixSort(arr, n); CourseNana.COM

printData(arr, n); return 0; CourseNana.COM

} CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Albany代写,CSI404代写,ECE404代写,Computer Architecture and Organization代写,MIPS代写,C代写,Assembly代写,Albany代编,CSI404代编,ECE404代编,Computer Architecture and Organization代编,MIPS代编,C代编,Assembly代编,Albany代考,CSI404代考,ECE404代考,Computer Architecture and Organization代考,MIPS代考,C代考,Assembly代考,Albanyhelp,CSI404help,ECE404help,Computer Architecture and Organizationhelp,MIPShelp,Chelp,Assemblyhelp,Albany作业代写,CSI404作业代写,ECE404作业代写,Computer Architecture and Organization作业代写,MIPS作业代写,C作业代写,Assembly作业代写,Albany编程代写,CSI404编程代写,ECE404编程代写,Computer Architecture and Organization编程代写,MIPS编程代写,C编程代写,Assembly编程代写,Albanyprogramming help,CSI404programming help,ECE404programming help,Computer Architecture and Organizationprogramming help,MIPSprogramming help,Cprogramming help,Assemblyprogramming help,Albanyassignment help,CSI404assignment help,ECE404assignment help,Computer Architecture and Organizationassignment help,MIPSassignment help,Cassignment help,Assemblyassignment help,Albanysolution,CSI404solution,ECE404solution,Computer Architecture and Organizationsolution,MIPSsolution,Csolution,Assemblysolution,