Question

Lab 6 Conditional Branching In this lab you will implement an algorithm for word-size signed integer division. Given 4 word-size values N (numerator), D (denominator), Q (quotient), and R (remainder). Signed integer division has 4 cases: N/D = Q r R, -N/D = -Q r -R, N/-D = -Q r R, -N/-D = Q r R The above can be implemented as follows: 1. Initialize sign case = 0 (positive N, positive D). 2. If N < 0 3. then: apply 2's complement to make it positive 4. increment sign case. 5. endif 6. If D < 0 7. then: apply 2's complement to make it positive 8. sign case = sign case + 2 9. endif 10. while (N ? D) 11. N = N - D 12. Increment Q 13. endw 14. R = N 15. if case = 1 16. then: apply 2's complement Q and R 17. elseif case = 2 18. then: complement Q 19. endif A word is made up of 2 bytes. To apply 2's complement to a word, complement each byte separately, then add 1. Create a special check for D = 0. If D = 0 then you can skip the while and write Q = 0, N = 0 to represent NaN (Not-a-Number). A similar check can be done for D = 1 for faster/efficient programming. Recommendation: Start by implementing the above algorithm for integer byte. Submitting an integer byte implementation of the assignment constitutes 85% effort.

          Lab 6
Conditional Branching

In this lab you will implement an algorithm for word-size signed integer division.

Given 4 word-size values N (numerator), D (denominator), Q (quotient), and R (remainder). Signed
integer division has 4 cases:
N/D = Q r R, -N/D = -Q r -R, N/-D = -Q r R, -N/-D = Q r R

The above can be implemented as follows:

1. Initialize sign case = 0 (positive N, positive D).
2. If N < 0
3. then: apply 2's complement to make it positive
4. increment sign case.
5. endif
6. If D < 0
7. then: apply 2's complement to make it positive
8. sign case = sign case + 2
9. endif
10. while (N ? D)
11. N = N - D
12. Increment Q
13. endw
14. R = N
15. if case = 1
16. then: apply 2's complement Q and R
17. elseif case = 2
18. then: complement Q
19. endif

A word is made up of 2 bytes. To apply 2's complement to a word, complement each byte separately, then add 1.

Create a special check for D = 0. If D = 0 then you can skip the while and write Q = 0, N = 0 to represent NaN (Not-a-Number). A similar check can be done for D = 1 for faster/efficient programming.

Recommendation: Start by implementing the above algorithm for integer byte. Submitting an integer byte implementation of the assignment constitutes 85% effort.
        
Show more…
Lab 6
Conditional Branching

In this lab you will implement an algorithm for word-size signed integer division.

Given 4 word-size values N (numerator), D (denominator), Q (quotient), and R (remainder). Signed
integer division has 4 cases:
N/D = Q r R, -N/D = -Q r -R, N/-D = -Q r R, -N/-D = Q r R

The above can be implemented as follows:

1. Initialize sign case = 0 (positive N, positive D).
2. If N < 0
3. then: apply 2's complement to make it positive
4. increment sign case.
5. endif
6. If D < 0
7. then: apply 2's complement to make it positive
8. sign case = sign case + 2
9. endif
10. while (N ? D)
11. N = N - D
12. Increment Q
13. endw
14. R = N
15. if case = 1
16. then: apply 2's complement Q and R
17. elseif case = 2
18. then: complement Q
19. endif

A word is made up of 2 bytes. To apply 2's complement to a word, complement each byte separately, then add 1.

Create a special check for D = 0. If D = 0 then you can skip the while and write Q = 0, N = 0 to represent NaN (Not-a-Number). A similar check can be done for D = 1 for faster/efficient programming.

Recommendation: Start by implementing the above algorithm for integer byte. Submitting an integer byte implementation of the assignment constitutes 85% effort.

Added by Maria R.

Close

University Physics with Modern Physics
University Physics with Modern Physics
Hugh D. Young 14th Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Lab 6 Conditional Branching In this lab, you will implement an algorithm for word-size signed integer division: Given 4 word-size values N (numerator), D (denominator); Q (quotient), and R (remainder): Signed integer division has 4 cases: ~N ~N D = Qr R, D =~Qr - R, ~D = ~Qr R ~D = Qr R The above can be implemented as follows: Initialize sign case = 0 (positive N, positive D): If N < 0 then: apply 2's complement to make it positive increment sign case. endif If D < 0 then: apply 2's complement to make it positive sign case = sign case +2 endif while (N > D) N=N-D Increment Q endw R=N if case = 1 then: apply 2's complement Q and R elseif case = 2 then: complement Q endif A word is made up of 2 bytes. To apply 2's complement to a word, complement each byte separately, then add 1. Create a special check for D = 0. If D = 0 then you can skip the while and write Q = 0, N = 0 to represent NaN (Not-a-Number): A similar check can be done for D = 1 for faster/efficient programming: Recommendation: Start by implementing the above algorithm for an integer byte. Submitting an integer byte implementation of the assignment constitutes 85% effort:
Close icon
Play audio
Feedback
Powered by NumerAI
Danielle Fairburn David Collins
Jennifer Stoner verified

Sri K and 54 other subject Physics 102 Electricity and Magnetism educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
6-in-signed-value-addition-by-checking-the-sign-of-inputs-and-output-we-can-recognize-whether-overflow-has-occurred-or-not-when-we-have-the-following-arithmeticlogic-unit-alu-providing-32-bi-65258

Akash M.

design-a-digital-system-that-multiplies-two-unsigned-binary-numbers-by-the-repeated-addition-method-for-example-to-multiply-5-by-4-it-adds-the-multiplicand-four-times-5-5-5-5-20-let-the-mult-83263

Adi S.

da-8-points-in-this-exercise-we-examine-in-detail-how-an-instruction-is-executed-in-a-single-cycle-datapath-_-problems-in-this-exercise-refer-to-clock-cycle-in-which-the-processor-fetches-th-26637

In this exercise, we examine in detail how an instruction is executed in a single-cycle datapath. Problems in this exercise refer to the clock cycle in which the processor fetches the following instruction word: 1000110010100110000000000011000. Assume that the data memory is all zeros and that the processor registers have the following values at the beginning of the cycle in which the above instruction word is fetched: a. What are the outputs of the sign-extend and the jump Shift-Left-2 (near the top of Figure 4.24) for this instruction word? (2 points) b. What are the values of ALU control unit's inputs (ALUOp and Instruction operation) for this instruction? (2 points) c. For the ALU and the two add units, what are their data input values? (2 points) d. What are the values of all inputs for the "Registers" unit? (2 points)

Sri K.


*

Recommended Textbooks

-
University Physics with Modern Physics

University Physics with Modern Physics

Hugh D. Young 14th Edition
achievement 1,088 solutions
Physics: Principles with Applications

Physics: Principles with Applications

Douglas C. Giancoli 7th Edition
achievement 1,321 solutions
Fundamentals of Physics

Fundamentals of Physics

David Halliday, Robert Resnick , Jearl Walker 10th Edition
achievement 1,779 solutions

*

Transcript

-
00:01 So here in this question considering number to be 32 bit integer, so short x that is equal to log to num plus 1 and here bit set is 16 b x...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever