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

What is error detection code, What is Error detection code? It is a bin...

What is Error detection code? It is a binary code that notice digital errors during transmission. The detected errors cannot be correct but the presence is shown.

Difference between packet switching and circuit switching, What are the adv...

What are the advantages and disadvantages of packet switching over circuit switching? The comparison of packet switching and circuit switching demonstrating advantages and disa

What is throughput of a system, Throughput of a system is? Ans. "Throug...

Throughput of a system is? Ans. "Throughput" of a system is no. of programs processed by this per unit time.

Verilog, http://www.cse.psu.edu/~dheller/cmpen331/Homework/Homework4.htmlwo...

http://www.cse.psu.edu/~dheller/cmpen331/Homework/Homework4.htmlwords accepted#

Posix threads and mutex, The objective of this practical assignment is to u...

The objective of this practical assignment is to use the POSIX environment to write a program that simulates the supply and demand between three processes: warehouse, factory and r

How to calculate the logic circuit outputs, How to Calculate the Logic Circ...

How to Calculate the Logic Circuit Outputs? Once the Boolean expression for a circuit output has been acquired, the output logic level can be determined for any set of input le

Explain about cseg segment, CSEG SEGMENT  ASSUME CS:CSEG, DS:CSEG, SS:CS...

CSEG SEGMENT  ASSUME CS:CSEG, DS:CSEG, SS:CSEG  ORG 100h START:MOV AX, CSEG; Initialise data segment  MOV DS, AX; register using AX  MOV AL, NUM1; Take the first num

Define smtp, SMTP Simple Mail Transfer Protocol, a protocol for sending...

SMTP Simple Mail Transfer Protocol, a protocol for sending e-mail messages among servers. Most e-mail systems that send mail over the Internet use SMTP to send messages from si

Determine the function of dynamic model, Determine the function of Dynamic ...

Determine the function of Dynamic model Dynamic model: Dynamic model describes how system responds to external events. The implementation of the control flow in a program must

Find farthest distance from exchange where subscriber locate, An exchange u...

An exchange uses a -40 V battery to drive subscriber lines. A resistance of 250 ohms is placed in series with the battery to protect it from short circuits. The subscribers are req

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