Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Branch Prediction Consider the pseudo code below. Using a 1-bit bimodal predicto

ID: 3579989 • Letter: B

Question

Branch Prediction Consider the pseudo code below. Using a 1-bit bimodal predictor, for each branch, keep track of the prediction and the true outcome in the tables below. Also, indicate what the prediction accuracies for each branch and for both. Assume, for each branch, the initial prediction is nottaken. Indicate a not-taken in the tables with a 0 and a taken with a 1.
Show your work to receive full credit.

while (1)
{
// Branch 1
for (i=0;i<5;i++)
{ // Do something }
   // Branch 2
for (j=0;j<7;j++)
  { // Do something }
}

Explanation / Answer

#include <stdio.h>

/* Iterative function to reverse digits of num*/
int reversDigits(int num)
{
    int rev_num = 0;
    while(num > 0)
    {
        rev_num = rev_num*10 + num%10;
        num = num/10;
    }
    return rev_num;
}

/*Driver program to test reversDigits*/
int main()
{
    int num = 4562;
    printf("Reverse of no. is %d", reversDigits(num));

    getchar();
    return 0;
}