binary division program for signed integer, Computer Engineering

The program division.c is available for download as part of this assignment. It is a binary division program which works for signed integers. It contains a function, div32, which does the signed division; and a main() program which tests division for several pairs of numbers. You should download, compile, and run it to see the output. Now, re-implement the binary division function, div32, 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 remainder pass by value

Although this is not quite the convention used by a "C" compiler (quotient and remainder 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.

Then, re-implement the main() program in MIPS assembly code to test the binary division function. The SPIM environment includes a number of SYSCALL functions for printing strings and integers. Test your functions with the same arrays of test cases given. Your results should be identical. Your assembly program must be fully documented, as follows:

First, at the start of each procedure (main and div32) you should have a list of all the registers that you use, and what each is used for. For example, you should have something like the following at the start of your div32 code (you will have many more registers, probably allocated differently; this is just to give the idea):

#--------------------------------------------------------------------------

# Procedure Name: int div32(long dividend, long divisor,

# long quotient, long remainder)

#

# Description:

#

# Register Allocation: $4: dividend (changed)

# $5: divisor (changed)

# ...

# $10: scratch

# ...

# $17: dividend_sign

# $18: divisor_sign

#--------------------------------------------------------------------------

Second, you should have a comment containing the "C" code that you are translating just before the assembly code implementing that "C" code. You should also have a comment at the end of every line of the assembly code. Here's an example:

#--------------------------------------------------------------------------

# if (dividend < 0) {

# dividend_sign = 1;

# dividend = -dividend;

# }

#--------------------------------------------------------------------------

slt $10, $4, $0 # Check if dividend less than 0

beq $10, $0, div20 # If not, skip to next case

li $17, 1 # dividend_sign = 1

negu $4, $4 # negate dividend

#--------------------------------------------------------------------------

# if (divisor < 0) {

# divisor_sign = 1;

# divisor = -divisor;

# }

#--------------------------------------------------------------------------

div20: slt $10, $5, $0 # Check if divisor less than 0

beq $10, $0, div30 # If not, skip ahead

li $18, 1 # divisor_sign = 1

negu $5, $5 # negate dividend

Posted Date: 3/1/2013 12:56:53 AM | Location : United States







Related Discussions:- binary division program for signed integer, Assignment Help, Ask Question on binary division program for signed integer, Get Answer, Expert's Help, binary division program for signed integer Discussions

Write discussion on binary division program for signed integer
Your posts are moderated
Related Questions
Define Cloud Computing with example. Cloud computing is a model for enabling convenient, on-demand network access to a shared pool of configurable computing resources (e.g., se

What is virtual memory? Method that automatically move program and datablocks into the physical main memory when they are needed for execution are known as virtual memory.

Line A Line is, on a simple level, a mark connecting 2 points. However, how lines are used in an image is extremely important. By varying the quality of line used in an image,

One of these objectives is related to costs. By going e-commerce, consumers will be able to submit their purchase requests to the sellers without paying a visit to their place. Thi

Full form of is DHCP: Dynamic Host Control Protocol. It is mainly used to bound MAC Addresses of system. Especially for Wireless System.

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4 Select a range of a

Drawbacks to having call centres overseas -  Culture and language problems -  Animosity to overseas call centres (resulting in loss of customers) -  need for extensive r

You have a file having sporting goods that are sold online. Every item record contains the item id, item name, item description, item category, item price, and the units in stock.

What are the lists of signal available? Terminating and suspending method Physical circumstances Available for the Programmer Fault in power supply

Explain the Executing Requests Using a Message-Passing Architecture Executing requests using a message-passing architecture requires good fundamental client-server programming