Question

9. The following C-like code calculates the greatest common divisor (GCD) of the two 8-bit positive integers a and b (Aside:

10. For problem 9, assume the input a-00011110, b-01010100, answer the output gcd in 8-bit format. gcd-

9. The following C-like code calculates the greatest common divisor (GCD) of the two 8-bit positive integers a and b (Aside: This is Euclid's algorithm from 300 BC). Complete the HLSM for the code (Answers are case sensitive) Inputs: byte a, byte b, bit go Outputs: byte gcd, bit done GCD while (1) ( while (!go); done 0 while (a!-b){ if(a>b){ a-a b else gcd-a done 1 Inputs: go (bit), a, b (8 bits) Outputs: done (bit), ged (8 bits) Local Registers: a reg (8 bits), b_reg (8 bits) a reg b reg) a reg:-a reg -b rejg a rega bregb doneo b reg b reg-a reg gcd:- Y done-Z
10. For problem 9, assume the input a-00011110, b-01010100, answer the output gcd in 8-bit format. gcd-
0 1
Add a comment Improve this question Transcribed image text
Answer #1

ns- Gvena 00011110 b = o101 01 00 GCD = greatest common divisor 0 GCD二 2

Add a comment
Know the answer?
Add Answer to:
9. The following C-like code calculates the greatest common divisor (GCD) of the two 8-bit positi...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone help convert this C code to HLSM (list local storage w bits and draw...

    Can someone help convert this C code to HLSM (list local storage w bits and draw HLSM)? Any help would be greatly appreciated. Inputs: A[128][8], go (bit), Outputs: sdiff (xx bits), done (bit) while(1){ while( !go ); done = 0; m = 127; n = 0; sdiff = 0; while(n < 64){ temp1 = A[n]; temp2 = A[m]; if (tempi < temp2) sdiff = sdiff + (temp2 – templ); else sdiff = sdiff + (temp1 - temp2); n = n...

  • Use R language to program Problem 1: Greatest Common Divisor (GCD) Please write two functions, g...

    Use R language to program Problem 1: Greatest Common Divisor (GCD) Please write two functions, g edi ) and gcdr , which both take two integers a, b and calculates their greatest common divisor (GCD) using the Euclidean algorithm gcdi () should do so using iteration while gcdr () should use recursion. Then write a third function, gcd(), which takes two integers a, band an optional third argument nethod which takes a charater string containing either "iterative" or "recursive", with...

  • We want to make a design that calculates the maximum difference between any two numbers within...

    We want to make a design that calculates the maximum difference between any two numbers within an array, a, consisting of 256 8-bit values stored in a register file 256x8. The high-level C code for this design is provided below. Convert this to a High-level state machine. Inputs: byte a [256), bit go Outputs: byte max_diff, bit done MAX_DIFF: while(1) { while( !go); done = 0; i 0; max = 0; min 255; // largest 8-bit value while( i <...

  • PYTHON In mathematics, the Greatest Common Divisor (GCD) of two integers is the largest positive integer...

    PYTHON In mathematics, the Greatest Common Divisor (GCD) of two integers is the largest positive integer that divides the two numbers without a remainder. For example, the GCD of 8 and 12 is 4. Steps to calculate the GCD of two positive integers a,b using the Binary method is given below: Input: a, b integers If a<=0 or b<=0, then Return 0 Else, d = 0 while a and b are both even do a = a/2 b = b/2...

  • C++ Problem 1 Write a function to calculate the greatest common divisor (GCD) of two integers...

    C++ Problem 1 Write a function to calculate the greatest common divisor (GCD) of two integers using Euclid’s algorithm (also known as the Euclidean algorithm). Write a main () function that requests two integers from the user, calls your function to compute the GCD, and outputs the return value of the function (all user input and output should be done in main ()). In particular, you will find this pseudocode for calculating the GCD, which should be useful to you:...

  • A)What is the maximum delay that can generated by an 8 bit Timer with a prescale...

    A)What is the maximum delay that can generated by an 8 bit Timer with a prescale divider value of 0 and a system clock frequency of 16 MHz? B) In the HCS12, port T is a bidirectional port. Write a short segment of code (C and Assembly) that illustrates how to initialize port T so that bits 7-4 may be used as outputs and bits 3-0 may be used as inputs: C)If you are using an output compare with interrupts...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT