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

Describe the role of software developers, Describe the role of Software dev...

Describe the role of Software developers Software developers have wide experience of tackling such issues. Students who develop software project spending days and nights strug

Explain variable-partition contiguous storage allocation, Explain the conce...

Explain the concept of variable-partition contiguous storage allocation. Suppose that we have 1024K main memory available in that 128K is occupied through operating system pro

Important terms related to systems, Purpose, Environment, Boundary, Inputs,...

Purpose, Environment, Boundary, Inputs, and Outputs are a number of important terms related to Systems. A System's objective/purpose is the reason for its existence and refe

What is core dump, Raises when accessing an unassigned memory location acce...

Raises when accessing an unassigned memory location accessing a null pointer

Discuss different mode of centralized stored program control, Explain SPC. ...

Explain SPC. Also discuss the different modes of Centralized SPC In stored program control systems, set of instructions or a program to the computer is stored into its memory a

Demultiplexers, Explain briefly about demultiplexers?

Explain briefly about demultiplexers?

Digital systems and microprocessors, Your logic function for this assignmen...

Your logic function for this assignment is to be derived from your own student number. The number 1224583 will be used as an example as to how you should derive your function and e

Explain the linux from scratch system, Problem 1 (a) Explain the RAID ...

Problem 1 (a) Explain the RAID system and explain all possible configurations. (b) Summarize design goals, features and specifications of the Linux ext2 file system. (c

What is telnet explain, Q. What is Telnet explain? TELNET stands for TE...

Q. What is Telnet explain? TELNET stands for TErminal NETwork. Telnet is both a protocol for connecting a local computer to a remote computer and a TCP/IP application. Telnet i

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