CSEE 3827: Homework 4 Due: 4/11/11

Similar documents
Typy danych. Data types: Literals:

MIPS Assembly Code Layout

Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm

Introduction to MIPS Assembly Programming

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Lab Work 2. MIPS assembly and introduction to PCSpim

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

Computer Systems Architecture

More MIPS: Recursion. Computer Science 104 Lecture 9

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

How To Write An Array In A Microsoft Zil

Figure 1: Graphical example of a mergesort 1.

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

CNC Transfer. Operating Manual

PCSpim Tutorial. Nathan Goulding-Hotta v0.1

J a v a Quiz (Unit 3, Test 0 Practice)

7-1. This chapter explains how to set and use Event Log Overview Event Log Management Creating a New Event Log...

Chapter 7 Event Log. 7.1 Event Log Management

Chapter 7 Event Log Overview

7-1. This chapter explains how to set and use Event Log Overview Event Log Management Creating a New Event Log...

VisionMate Flat Bed Scanner 2D Tube Barcode Reader

Install Java Development Kit (JDK) 1.8

Lecture 5: Java Fundamentals III

7-1. This chapter explains how to set and use Event Log Overview Event Log Management Creating a New Event Log...

Creating a Storyboard using Microsoft Word

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

Using these objects to view the process of the whole event from triggering waiting for processing until alarm stops. Define event content first.

Pemrograman Dasar. Basic Elements Of Java

sqlite driver manual

System Calls Related to File Manipulation

Vim, Emacs, and JUnit Testing. Audience: Students in CS 331 Written by: Kathleen Lockhart, CS Tutor

Java Crash Course Part I

Project 2: Bejeweled

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

13 Classes & Objects with Constructors/Destructors

Number Representation

Illustration 1: Diagram of program function and data flow

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

Sources: On the Web: Slides will be available on:

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, Introduction 1. 2 Invoking Shell Scripts 2

csce4313 Programming Languages Scanner (pass/fail)

An Incomplete C++ Primer. University of Wyoming MA 5310

Moving from CS 61A Scheme to CS 61B Java

iphone Objective-C Exercises

Sample CSE8A midterm Multiple Choice (circle one)

DBF Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 7

Object-Oriented Programming in Java

Basics of I/O Streams and File I/O

5 MIPS Assembly Language

HW3: Programming with stacks

CAPIX Job Scheduler User Guide

Lecture 25 Systems Programming Process Control

Translating C code to MIPS

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

HP Universal Print Driver Series for Windows Active Directory Administrator Template White Paper

PRI-(BASIC2) Preliminary Reference Information Mod date 3. Jun. 2015

2D Data Matrix Supplier Label Specification

How to use SURA in three simple steps:

1.5 MONITOR. Schools Accountancy Team INTRODUCTION

Programming Languages CIS 443

Inside the Java Virtual Machine

Using C to Access Data Stored in Program Space Memory on the TMS320C24x DSP

Introduction to MIPS Programming with Mars

CISC 181 Project 3 Designing Classes for Bank Accounts

3 - Lift with Monitors

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Using C to Access Data Stored in Program Memory on the TMS320C54x DSP

Syscall 5. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

COMP Upload File Management and Processing

CS 106 Introduction to Computer Science I

User's Manual SAM 2.7 PPC 5.3.3

How to Write a Simple Makefile

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Network Detective Client Connector

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Bash shell programming Part II Control statements

Changing the Display Frequency During Scanning Within an ImageControls 3 Application

ECE 341 Coding Standard

Visual Basic Programming. An Introduction

VMware vcenter Configuration Manager Software Provisioning Components Installation and User Guide

Getting Started with R and RStudio 1

What is a Mail Merge?

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

Chapter 3 Claims June 2012

TECHNICAL DOCUMENTATION FOR VARUBREV

Final Software Tools and Services for Traders

Assembly Language Programming

Programming Database lectures for mathema

Dreamweaver Tutorials Creating a Web Contact Form

Managing Code Development Using CCS Project Manager

CS 348: Introduction to Artificial Intelligence Lab 2: Spam Filtering

Caml Virtual Machine File & data formats Document version: 1.4

Repetition Using the End of File Condition

NESTML Tutorial. I.Blundell, M.J.Eppler, D.Plotnikov. Software Engineering RWTH Aachen.

Unix Scripts and Job Scheduling

CP Lab 2: Writing programs for simple arithmetic problems

Transcription:

CSEE 3827: Homework 4 Due: 4/11/11 For this assignment you will write MIPS code, which you can test by simulating it with SPIM, a MIPS simulator. SPIM is a command line tool available on cunix (cunix.cc.columbia.edu). We have provided templates which you must use for your solutions to these problems. You can download the templates as follows: Download the templates from http://www.cs.columbia.edu/ martha/courses/3827/sp11/homeworks/templates.tar. Unpack the templates: % tar xvfz templates.tar.gz The preceding step will create a directory named templates which you should rename to your own UNI, e.g., % mv templates mak2191. To turn in this homework, you will recreate a tarball with your solutions. When we unpack this tarball we should find a directory named with your UNI containing two files: min.s and histogram.s. Make sure the directory containing your solutions is named after your UNI. Make sure your solutions use the templates and preserve the original filenames. Go to the directory above the one containing your solutions and create a tarball, e.g., % tar cvfz mak2191.tar.gz mak2191/ For help using spim on cunix, run spim with no arguments, followed by the command help 1. min.s The purpose of this problem is to have you write a simple program and get you accustomed to using spim. You should complete it before moving on to the other portions of the assignment. PROBLEM 1 Write a function that takes two integer arguments and and returns the minimum of the two. If it were a C function the declaration would be: int min ( int a, int b) Your implementation must adhere to all MIPS calling conventions, and use exactly this template. Modify the file only where indicated. #. data newline :. asciiz "\n". text. globl main main : addi $a0, $zero, 10 addi $a1, $zero, 20 jal min move $a0, $v0 jal print # should print 10 addi $a0, $zero, 10 addi $a1, $zero, -10 jal min move $a0, $v0 jal print # should print -10 li $v0, 10 # exit 1

min : Your implementation of min () here. print : li $v0, 1 2. histogram.s The last three problems culminate in the construction of a histogram printer. The file contains the full specifications for each component. # Problems 2-4 This series of problems culminates in the implementation of a histogram function which counts the number of occurrences of each character in a string, and prints the resulting histogram to the screen. For example, the histogram for the string " Hello, World!" is:!, H W d e l o r It is HIGHLY RECOMMENDED that you implement these functions in problem order because the latter ones will depend on a working implementation of the earlier ones. NB: At the bottom of this file several helper functions are provided for your use. NB: Each of your functions must adhere to MIPS calling conventions, and take and return the arguments exactly as specified ( including their order ). We have provided code in the body of main to test each function individually. Simply uncomment the tests that you would like to run. #. Data min_char :. asciiz " " max_char :. asciiz "~" bar :. asciiz " " separator :. asciiz " " newline :. asciiz "\n" hello :. asciiz " Hello, World!" gettysburg :. asciiz " Four score and seven years ago our fathers brought forth on this continent, a n. text. globl main main : PROBLEM 2 TEST CODE ( print_bucket ) 2

li $a0, 42 # $a0 = * li $a1, 10 # $a1 = 10 jal print_bucket # should print : "* " on its own line li $a0, 45 # $a0 = - li $a1, 12 # $a1 = 12 jal print_bucket # should print : "- " on its own line li $a0, 80 # $a0 = P li $a1, 8 # $a1 = 8 jal print_bucket # should print : " P " on its own line PROBLEM 3 TEST CODE ( count ) li $a0, 108 # $a0 = l la $a1, hello jal count move $a0, $v0 jal print_int # should print "3" li $a0, 33 # $a0 =! la $a1, hello jal count move $a0, $v0 jal print_int # should print "1" li $a0, 98 # $a0 = b la $a1, gettysburg jal count move $a0, $v0 jal print_int # should print "13" PROBLEM 2 TEST CODE ( histogram ) la $a0, hello jal histogram la $a0, gettysburg jal histogram li $v0, 10 # exit # PROBLEM 4 Implement the histogram function : void histogram ( char * s) For each character c between * min_char and * max_char, histogram counts the number of occurrences of c in s, and prints out a bucket in the histogram for all non - zero counts. # histogram : Your code here # 3

PROBLEM 3 Implement the count function : int count ( char c, char * s) count counts the number of instances of a character ( c) in a string (s). # count : Your code here PROBLEM 2 Implement the print_bucket function : void print_bucket ( char c, int n) print_bucket takes two arguments, a character ( c) and an integer ( n) indicating how many instances of c were found in some string. This function should print the corresponding bucket in the histogram. A bucket consists of a label, followed by n bars, followed by a newline. For example, print_bucket ( a, 2) should print " a \ n". # print_bucket : Your code here HELPER FUNCTIONS print_label : # void print_label ( char c) addi $sp, $sp, -4 sw $ra, 0( $sp ) jal print_char jal print_separator lw $ra, 0( $sp ) addi $sp, $sp, 4 print_bar : # void print_bar () la $a0, bar print_separator : # void print_separator () la $a0, separator print_newline : # void print_newline () print_char : li $v0, 11 # void print_char ( char c) 4

print_int : li $v0, 1 # void print_int ( int i) 5