a5solns - Department of Electrical Engineering Course...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Department of Electrical Engineering Course ECSE-221, Fall 2003 Introduction to Computer Engineering I Assignment 5 Assembly Language Programming II Due: Wednesday, November 26 th , 2003 Question 1 The binary division algorithm presented in the notes is quite inefficient as it can require up to 2N ALU operations to divide an N-bit dividend by an N-bit divisor. A better approach is the non- restoring division algorithm (see Patterson and Hennessy, Page 333, Question 4.54) which performs the restoration step on the following iteration of the algorithm. From the information provided in the text, figure out what modifications are necessary to the existing algorithm. Then modify the C code you wrote for Assignment 4 and repeat Question 1, running the same test examples. Next, perform the same modifications on the assembly version of your algorithm and repeat Question 2. (Note: the required changes are quite minor for both the C and assembly versions of the code). Question 2 Write a C function to compute the 64-bit product of two 32-bit signed integers using Booths multiplication algorithm. Your algorithm must adhere strictly to the datapath shown on page 257 of the text (Figure 4.31), with the necessary modifications to implement Booth (as discussed in class). Code your algorithm according to the following prototype: void boothmult(long multiplier, long multiplicand, long *product); Validate your code by writing a suitable test program. To make implementation in Question 3 easier, it is suggested that you prepare a table of test cases that your main program iterates through. Question 3 Implement the boothmult function in MIPS assembly code. Arguments are to be passed ON THE STACK as follows: addi $sp, $sp, -12 sw $4, 0($sp) # multiplier sw $5, 4($sp) # multiplicand sw $6, 8($sp) # pointer to return (product) jal boothmult addi $sp, $sp, 12 The 64-bit product is returned in an array of length 2, with the msw in the first location and the lsw in the second. Adhere to the conventions on Page 26 of the Module 4 notes for passing arguments on the stack. Test your function with the same table of test cases that you used in Question 1. Your results should be identical. FPF/November 11, 2003 div32nrd.c 11/25/03 11:22:05 PM Page 1 /*----------------------------------------------------------------------*/ /* File Name: divnrd32.c */ /* Description: A modified version of the simple binary division */ /* algorithm that supports non-restoring division. */ /* The code is virtually identical. As before the */ /* main is a command line procedure for testing the */ /* div32 function which implements the algorithm. */ /* Author: F.P. Ferrie */ /* Date: Novermber 11, 2003. */ /* Modifications: None */ /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ /* Includes */ /*----------------------------------------------------------------------*/ #include <stdio.h>#include <stdio....
View Full Document

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

Page1 / 36

a5solns - Department of Electrical Engineering Course...

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

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