Vous êtes sur la page 1sur 5

SVU CE450 Spring 2013 StudentID : A3082 Student Name : Moulika Bandi Homework #2 Due date: 2/2/2013

In this homework, you are to get familiar with the MIPS Cross Compiler, and run a compilation through the C-Compiler made available by MentorGraphics for free (lite version), URL: http://www.mentor.com/embedded-software/sourcerytools/sourcery-codebench/editions/lite-edition/ You will do the following the steps as below: 1. Download and install the C Cross compiler as above, After installation, take a screen shot of the installation completion using screen capture utility snipping tool (for window), and print a hardcopy (proof of your installation) 2. Compiler the provided C program below into MIPS assembly code. You will need to modify the constant in the for loop below by replacing with your student id, and the student id comments description to identify yourself. Print out a hardcopy of the compiled assembly code. Highlight the where the constant is in the assembly code. 3. Load the compiled assembly program to the SPIM simulator for simulation. First, read the manual from the Compiler installation directory/program to figure out what correct compiler options needed to compile to assembly code. Next step, in order to run the simulation, you will need to comment out some programming directives in the compiled assembly code to bypass for SPIM simulator (see HW#1 assembly code example). Finally, show the final result of all CPU registers, Memory content, and program counter. Take a screen shot again, and print the hardcopy. Using a high-light marker, point out the PC, r28, r29, and r31 values. main.c

// My student id = A3082, last 2 digits (82) of my student id is the constant below #include <stdio.h> int main() { int i; int sum=0; for (i=0; i<=82; i++) sum += i; return sum;} CE450 COMPUTER ARCHITECTURE Spring 2013

ASSIGNMENT 2 ID Number: A3082 Name : Moulika Bandi 1) Screenshot of Code Bench Lite

2) Program with my ID Number main.c

// My student id = A3082, last 2 digits (82) of my student id is the constant below #include <stdio.h> int main() { int i; int sum=0; for (i=0; i<=82; i++) sum += i; return sum; } Assembly Code .file 1 "main.c" # .section .mdebug.abi32 # .previous # .gnu_attribute 4, 1 # .abicalls .option pic0 .text .align 2 .globl main .set nomips16 .set nomicromips .ent main # .type main, @function main: .frame $fp,24,$31 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-24 sw $fp,20($sp) move $fp,$sp sw $0,12($fp) sw $0,8($fp)

# vars= 8, regs= 1/0, args= 0, gp= 8

b nop $L3: lw lw addu sw lw addiu sw $L2: lw slt bne nop lw move lw addiu j nop .set .set .end .size .ident

$L2

$3,12($fp) $2,8($fp) $2,$3,$2 $2,12($fp) $2,8($fp) $2,$2,1 $2,8($fp) $2,8($fp) $2,$2,83 $2,$0,$L3 $2,12($fp) $sp,$fp $fp,20($sp) $sp,$sp,24 $31 macro reorder main main, .-main "GCC: (Sourcery CodeBench Lite 2012.09-99) 4.7.2"

# #

3) PC Values and Registers PC Value and Registers

PC value

Register Values

Vous aimerez peut-être aussi