这是一个加拿大C语言Linux编程的作业代写
Objectives
Write C programs that perform the followings:
1. Adds a twos complement binary number to another twos complement binary number.
2. Subtracts a twos complement binary number from another twos complement binary
number.
3. Multiplies a twos complement binary number by another twos complement binary
number.
4. Divides a twos complement binary number by another twos complement binary
number.
5. Adds a signed integer number with another signed integer number.
6. Subtracts a signed integer number from another signed integer number.
7. Multiplies a signed integer number by another signed integer number.
8. Divides a signed integer number by another signed integer number.
Specifications
Add operation on two twos complement numbers are very simple, bitwise addition of two
numbers always yields the expected result, irrespective of their sign bit values. If two numbers
are added, and both are either positive or negative, then overflow occurs if and only if the result
has the opposite sign of the numbers that have been added.
To subtract a twos complement number (subtrahend) from another twos complement number
(minuend), we need to take the 2’s complement (negation) of the subtrahend and add it to the
minuend.
We use Booth’s Multiplication Algorithm to multiply one twos complement number
(multiplicand) by another twos complement number (multiplier). Following is the flowchart of
Booth’s Multiplication Algorithm. The flowchart assumes A, Q, and M are 32-bit registers and Q-
1 is a 1-bit register. Multiplicand and Multiplier are loaded into M and Q respectively. Both A and
Q-1 are initialized to zero to start with. At the completion of the algorithm the result of the
multiplication operation is available in A and Q registers. Register A holds the most significant 32
bit and Q holds the least significant 32 bit of the result.