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 cache memory, What is cache memory? The small and fast RAM unit...

What is cache memory? The small and fast RAM units are known as caches. When the implementation of an instruction calls for data located in main memory, the data are obtained a

What is the function of the correction system, What is the function of the ...

What is the function of the correction system? The correction system handles changes to internal system components. Like as objects of the ABAP/4 Dictionary.

Describe about immediate addressing mode, Q. Describe about Immediate Addre...

Q. Describe about Immediate Addressing mode? When an operand is interpreted as an immediate value for example LOAD IMMEDIATE 7 it is actual value 7 which is put in CPU register

Pre-os and runtime sub-os functionality, In a raw Itanium, a 'Processor Abs...

In a raw Itanium, a 'Processor Abstraction Layer' (PAL) is incorporated in system. When it's booted PAL is loaded in the CPU and provides a low-level interface which abstracts a nu

Explain language processing, System Software 1. Explain language proces...

System Software 1. Explain language processing? Explain its activities in detail. 2. Discuss briefly about Assembler directives. Also explain about Macro definition and call

Communication of request/response - procedural interaction, Explain the Com...

Explain the Communications of Request/Response Communications requirements for message or procedural- based interaction are very similar. Application interaction (client-server

Explain the fork-join, Explain the fork-join? fork-join: It is prim...

Explain the fork-join? fork-join: It is primitives in a programming language of higher level for implementing interacting processes. The syntax is as given below: fork

What is the scope of public members in all classes, What is the Scope of pu...

What is the Scope of public/private/friend/protected/protected friend?    Scope of public/private/friend/protected/protected friend. Visual Basic/Visual C# Public/pub

Which scheduler select process from secondary storage device, Which schedu...

Which scheduler selects processes from secondary storage device? Ans. Medium term scheduler selects processes from secondary storage device.

Illustration of parallel programming environments, Q. Illustration of paral...

Q. Illustration of parallel programming environments? Let's discuss illustrations of parallel programming environments of Intel paragaon XP/S and Cray Y-MP software. The Cra

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