Question: assembly masm615: Theory Division using shift Two numbers A (a n a n-1 ... a 2 a 1 a 0 ) and B (b n

assembly masm615:

Theory

Division using shift

Two numbers A (an an-1 ... a2 a1 a0) and B (bn bn-1 ... b2 b1 b0). The division of A/B yields a quotient Q (bn qn-1 ... q2 q1 q0) and a remainder R that can be calculated by a series of shifts and subtractions.

Algorithm:(note:

1. Initialize i = n, Q = 0, Y = 0

2. Y = (Y i

3. If Y >= B then: {Q = Q + 1, Y = Y - B}

4. i = i - 1

5. If i > 0 then goto 2

6. R = Y

Assignment

Your assignment will be to implement division suing shift instruction and conditional instructions and Make sure your code works for 0's as arguments.

here is an example of a previous code that solves for Z=5x/4 + 2y/3, just to show you the structure and the simplicity of how the code should be:assembly masm615: Theory Division using shift Two numbers A (an an-1 ...

MODEL SMALL 386 STACK DATA. SBYTE 1, 16 28 88 100 116 68 104 92 40 52, 128 80 -8, 64 76 56 -44, 32 -20 Y SWORD 32765 16373 1965 -22927, 29491 7, 3271 26215 6559 16387, 13111, 98 35, 328 3, -6545, -9823, -13099, 22937, 19663, z SWORD 20 DUP CODE MAIN PROC FAR STARTUP program MOV SI 0 MOV CX, 20 L1 MOVSX AX, XCESI we are in a byte so its fine MOV BX, 5 IMUL BX MOV BX, 4 IDIV BX MOV DI AX MOV AK Y 2 ESI because we are going to a word MOV BX, 2 IMUL BX MOV BX 3 IDIV BX MOV BP, AK ADD DI BP MOV 202 ESI DI INC ESI Loop L1 EXIT MAIN ENDP END MODEL SMALL 386 STACK DATA. SBYTE 1, 16 28 88 100 116 68 104 92 40 52, 128 80 -8, 64 76 56 -44, 32 -20 Y SWORD 32765 16373 1965 -22927, 29491 7, 3271 26215 6559 16387, 13111, 98 35, 328 3, -6545, -9823, -13099, 22937, 19663, z SWORD 20 DUP CODE MAIN PROC FAR STARTUP program MOV SI 0 MOV CX, 20 L1 MOVSX AX, XCESI we are in a byte so its fine MOV BX, 5 IMUL BX MOV BX, 4 IDIV BX MOV DI AX MOV AK Y 2 ESI because we are going to a word MOV BX, 2 IMUL BX MOV BX 3 IDIV BX MOV BP, AK ADD DI BP MOV 202 ESI DI INC ESI Loop L1 EXIT MAIN ENDP END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!