# CMPEN 331 Pennsylvania State University Emulating DIVU with MIPS instructions Worksheet

Description

3 attachmentsSlide 1 of 3attachment_1attachment_1attachment_2attachment_2attachment_3attachment_3

Unformatted Attachment Preview

MIPs opcode map (COD Figure A.10.2).
Left Shift and Subtract Division Hardware
divisor
subtract
32-bit ALU
dividend
remainder
quotient
ShiftReg64
Division supplement.1
shift
left
Control
Left Shift and Subtract Restoring Division
Hardware (4-bit) [ example: 6 divided by 2]
0010
=2
(1 1 1 0 = – 2)
divisor
subtract
4-bit ALU
dividend
remainder
quotient
ShiftReg8
Iter 1:sub
Iter 2:sub
Iter 3:sub
Iter 4:sub
0000
0000
1110
0000
0001
1111
0001
0011
0001
0010
0000
0110
1100
1100
1100
1000
1000
1000
0000
0001
0010
0011
shift
left
Control
=6
Init Done
rem neg, so Q3 bit = 0
restore remainder
rem neg, so Q2 bit = 0
restore remainder
rem pos, so Q1 bit = 1
rem pos, so Q0 bit = 1
= 3 with 0 remainder
Division supplement.2
Previous Example, Step by Step
State of ShiftReg8 =
{rem, quot}
How we got to that state
0000 0110
initialize remainder | quotient with 0 | dividend
0000 1100
shift left 1 (these two steps collectively represent initialization)
1110 1100
trial subtract (remainder – divisor, 0000 – 0010 is 1110)
set the lsb of quotient to 0
0000 1100
trial subtract result is negative, restore the previous remainder
0001 1000
shift left
1111 1000
trial subtract (0001 – 0010 is 1111)
set the lsb of quotient to 0
0001 1000
trial subtract result is negative, restore the previous remainder
0011 0000
shift left
0001 0001
trial subtract (0011 – 0010 is 0001)
set the lsb of quotient to 1
0010 0010
shift left
0000 0011
trial subtract (0010 – 0010 is 0000)
set the lsb of quotient to 1
lsb of quotient is set to complement of msb of trial subtract result
Division supplement.3
Non-restoring division

Don’t update the register if the result would be negative (so you don’t
have to restore it) …

HW way: Pre-compute both possible updates:
Possible update 1: subtract and shift, append 1
Possible update 2: just shift, append 0
Mux based on sign bit of subtraction output

SW way: Check and branch
shouldSubtract = divisor

attachment

1 Script

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

## Reviews, comments, and love from our customers and community

### Article Writing

Great service so far. Keep doing what you do, I am really impressed by the work done.

Researcher

### PowerPoint Presentation

I am speechless…WoW! Thank you so much! Definitely, the writer is talented person. She provided me with an essay a day early before the due date!

#### Stacy V.

Part-time student

### Dissertation & Thesis

This was a very well-written paper. Great work fast. I was in pretty desperate need for help to finish this paper before the due date, which was in nine hours.

Student

### Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time. Kate did a WONDERFUL job. I would highly recommend her.

Student

### Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more. Very good at communicating & fast at replying. And change & corrections she put in the effort to go back and change it!

Student

### Essay (Any Type)

On time, perfect paper. All concerns & matters I had Tom was able to answer them! I will definitely provide him with more orders!

Student

### Case Study

Awesome! Great papers, and early! Thank you so much once again! Definitely recommend to trust James with your assignments! He won’t disappoint!

#### Kaylin Green

Student

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Researcher

### Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. It’s like having a tutoring service available (:

Customer

### Coursework

Perfect!I only paid about \$80, which i think was a good price considering what my paper entailed. My paper was done early and it was well written!

Student