binary division program for signed integer, Computer Engineering

Assignment Help:

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


Related Discussions:- binary division program for signed integer

Define the system users, Q. Define the System users? System users are d...

Q. Define the System users? System users are defined as the people who employ information systems or who are affected by information system on a regular basis i.e. validating,

First in first out method, The First In First Out method assumes items of s...

The First In First Out method assumes items of stocks are issued in the same order as they are received. Thus the goods received first are assumed to be the first to be issued .Any

Customer credit-rating software , Gordon Grant, majority shareholder and Ch...

Gordon Grant, majority shareholder and Chief Executive Officer of Finance-IT Ltd, is determined to be one of the entrepreneurs making money out of the recession. He started the fir

What are the various components in sequence diagrams, ? Actor: Actor shows ...

? Actor: Actor shows an external user / end user who interact with the system. ? Object: Object is shown by one of components of the system. ? Unit: A unit is a subsystem, o

Create simple algebraic expression from k-map, Q. Create simple algebraic e...

Q. Create simple algebraic expression from K-Map? Now create simple algebraic expression from K-Map. These expressions are created by employing adjacency if we have 2 adjacent

Binary floating-point number range, Q. Binary floating-point number range? ...

Q. Binary floating-point number range? Smallest Negative number   Maximum mantissa and maximum exponent     =    - (1 -2 -24 ) × 2 127   Largest negative number

Illustrate processor arrangements, Q. Illustrate processor arrangements? ...

Q. Illustrate processor arrangements? HPF$ PROCESSORS P2 (4, 3) !HPF$ TEMPLATE T2 (17, 20) !HPF$ DISTRIBUTE T2 (BLOCK, *) ONTO P1 Means that first dimension of T2 woul

Application and factors related to scanners, Q. Application and factors rel...

Q. Application and factors related to Scanners? When you purchase a scanner there are various factors which can be looked at: Compatibility of Scanner with your Computer, The T

The void type is used for, The void type is used for  The void type is ...

The void type is used for  The void type is used to make generic pointers.

What is clearquest, Rational ClearQuest is a change-request management tool...

Rational ClearQuest is a change-request management tool that tracks and handles defects and change requests all through the development process. With ClearQuest, you can manage eac

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd