Ass4 - Department of Electrical Engineering Course...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Department of Electrical Engineering Course ECSE-221, Fall 2003 Introduction to Computer Engineering I Assignment 4 Introduction to Assembly Language Programming Due: Monday, March 17 th , 2008, at 5:00 pm in the Trottier assignments box Question 1 A useful exercise in understanding assembly language and its relation to machine language is to write a short program and translate it by hand. Write a program, which we’ll call countbits, that counts the number of bits set to 1 in $4 and returns the result in $6. In writing your code, it will not be necessary to preserve context (it will be entered directly from main). You program must be relocatable , i.e., it should run from any location in memory provided that it is properly loaded on a word boundary. Next, translate your program to machine code. Although it might be tempting to simply let the SPIM assembler do this, the exercise is useful way of learning the MIPS instruction formats. Refer to the text for descriptions of MIPS assembly language instructions and the corresponding machine codes. Finally, load your program at 0x400100 and execute it. A before and after screenshot will suffice to demonstrate correct loading and functioning of your program. Note: The following method can be used to load and execute your hand-assembled machine code: .text 0x400100 # This specifies where the code is loaded .globl main main: .word 0xabcd0123 # Yes, the assembler allows you to define .word 0xabcd3210 # data in the text segment. It is under- etc… # stood that this corresponds to machine # instructions. 1/17
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Question 2 Implement the binary division function you wrote in Assignment 1, Question 5, in MIPS assembly code, assuming the following convention for passing arguments: Register Argument Mechanism $4 dividend pass by value $5 divisor pass by value $6 quotient pass by value $7 rmdr pass by value $8 status return pass by value Although this is not quite the convention used by a “C” compiler (quotient and rmdr are pointers and would otherwise by passed by reference), we will use it here since argument passing mechanisms have not been dealt with in detail at this point in the course. In coding your function it is absolutely essential that the context of the calling program is fully preserved. You will also need to write a suitable test program. The SPIM environment includes a number of SYSCALL functions for printing strings and integers. Test your functions with the same table of test cases that you used in Assignment 1. Your results should be identical. FPF/March 3, 2008. 2/17
Background image of page 2
3/17
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4/17
Background image of page 4
5/17
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6/17
Background image of page 6
7/17
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8/17
Background image of page 8
9/17
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#----------------------------------------------------------------------------- # Procedure Name: int div32(long dividend,long divisor, # long *quotient, long *rmdr); # # Description: Implements a binary division algorithm using # shift and subtract. Dividend and divisor are # passed in registers $4 and $5 respectively, with # quotient and remainder returned in $6 and $7. # # Notes:
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/21/2008 for the course ESCE 221 taught by Professor Ferrie during the Spring '08 term at McGill.

Page1 / 17

Ass4 - Department of Electrical Engineering Course...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online