1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Roman55 [17]
3 years ago
5

Programs for embedded devices are often written in assembly language. Some embedded processors have limited instructions, like M

ARIE. Create a MARIE program which determines whether a given address is a cache hit or not. For this assignment, the cache is 2-way set associative, addresses are 8 bits, blocks are 8 bytes, and the cache has 8 blocks.
Requirements
1. The program must be written in MARIE.
2. The input is a hex address (2 hex digits), the output is 1 for a cache hit and 0 for a cache miss.
3. The cache table is
Set 0 1 5
Set 1 2 4
Set 2 3 2
Set 3 6 0
4. Unlike a real memory system, for this assignment, the cache table won’t change on a cache miss.
Hints: 1.
You have already written a multiply subroutine for MARIE. You could use a similar integer divide subroutine for this. It could return both a quotient and a remainder.
2. I recommend writing this in Java or C++ first to test your algorithm. Write the divide method using repeated subtraction as you will in MARIE.
3. The textbook describes the LoadI instruction, but the MARIE simulator does not recognize that. You can accomplish the same thing using Clear and AddI.
Upload: Your MARIE source file (.mas)
Sample Output
Input: B5, Output: 0
Input: A5, Output: 1
Input: 6C, Output: 0
Input: 7D, Output: 0
Input: 8B, Output: 1
Computers and Technology
1 answer:
oksano4ka [1.4K]3 years ago
4 0

Answer:

#include <iostream>

using namespace std;

int main()

{

   char address[2];

   int tag, firstBit, secondBit, setNumber;

   int cache[4][2]={{1,5}, {2,4}, {3,2}, {6,0}};

   cout << "Enter the address as hex(in small letters: "<

   cin >> address;

   for (int i < 0; i < 8; i++){

       if (address[0] == '0'){

           tag = 0;

           firstBit = 0;

        } else if (address[0] == '1'){

           tag = 0;

           firstBit = 1;

        } else if (address[0] == '2'){

           tag =1;

           firstBit = 0;

        } else if (address[0] == '3'){

           tag = 1;

           firstBit = 1;

        } else if (address[0] == '4'){

           tag = 2;

           firstBit = 0;

        } else if (address[0] == '5'){

           tag = 2;

           firstBit = 1;

        }  else if (address[0] == '6'){

           tag = 3;

           firstBit = 0;

       } else if (address[0] == '7'){

           tag = 3;

           firstBit = 1;

       }  else if (address[0] == '8'){

           tag = 4;

           firstBit = 0;

       } else if (address[0] == '9'){

           tag = 4;

           firstBit = 1;

       }   else if (address[0] == 'A'){

           tag = 5;

           firstBit = 0;

       } else if (address[0] == 'B'){

           tag = 5;

           firstBit = 1;

       }  else if (address[0] == 'C'){

           tag = 6;

           firstBit = 0;

       } else if (address[0] == 'D'){

           tag = 6;

           firstBit = 1;

        }  else if (address[0] == 'E'){

           tag = 7;

           firstBit = 0;

       } else if (address[0] == 'F'){

           tag = 7;

           firstBit = 1;

       } else{

           cout<<"The Hex number is not valid"<< endl;

        }

   }

   if(address[1]>='0' && address[1]<'8'){

       secondBit = 0;

  }  else if(address[1]=='8'|| address[1]=='9'||(address[1]>='a' && address[1]<='f')){

       secondBit = 1;

   }  else{

       cout<<"The Hex number is not valid"<< endl;  

       return 0;

   }

   setNumber = firstBit * 2 + secondBit;

   if(cache[setNumber][0]==tag || cache[setNumber][1]==tag){

       cout<<"There is a hit";

   } else{

       cout<< "There is a miss";

   }

   return 0;

}

Explanation:

The C++ source code prompts the user for an input for the address variable, then the nested if statement is used to assign the value of the firstBit value given the value in the first index in the address character array. Another if statement is used to assign the value for the secondBit and then the setNumber is calculated.

If the setNumber is equal to the tag bit, Then the hit message is printed but a miss message is printed if not.

You might be interested in
Solve this for brainlest​
saw5 [17]

Answer:

which chapter is this

Explanation:

6 0
3 years ago
How does one select an entrepreneurial activity?
dem82 [27]
<span>Entrepreneurial activity is a human action with the goal of the generation of value, through the creation or expansion of economic activity. Several things must be taken into consideration before starting an </span><span>entrepreneurial activity but the most important is :
- the benefits it will give (financial but also personal , will you be satisfied doing that activity and will the activity bring financial benefits to you?
If yes, then you can do this activity.
</span>
6 0
4 years ago
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive.
puteri [66]

Answer:

import java.util.Scanner;

public class num4 {

   public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

     int sumOdds =0;

     int sumEvens =0;

     int num;

     do{

         System.out.println("Enter positive integers");

         num = in.nextInt();

         if(num%2==0){

             sumEvens+=num;

         }

         else if (num%2!=0){

             sumOdds+=num;

         }

     }while (num>0);

       System.out.println("The sum of evens: "+sumEvens);

       System.out.println("The sum of odds: "+sumOdds);

   }

}

Explanation:

  • Import Scanner class to prompt and receive user input
  • Declare the following variables and initialize them int sumOdds =0, int sumEvens =0, int num;
  • Create a do....while loop That continously prompts user to enter a positive number. The loop should terminate when a negative number is enters (n<=0)
  • Within the while loop use an if condition with the modulo (%) operator to determine even and odd numbers and add to the respective variables
  • Outside of the while loop Print sum of odds and sum of evens

5 0
3 years ago
I accidentally pressed the challenge button while I was scrolling through. I didn't mean to press that challenge, instead of the
kondor19780726 [428]

Answer:

Can u pls answer my questions I’m so stuck and I need them by tmrw or today pls I don’t know how to get ahold of u

Explanation:

5 0
4 years ago
Read 2 more answers
Auditors often make use of computer programs that perform routine processing functions, such as sorting and merging. These progr
ohaa [14]

Answer:

UTILITY PROGRAM

Explanation:

Utility program are program that perform routine processing function such as sorting and merging. They are often used by auditors to performs a very specific task, usually related to managing system resources. It contain a number of utilities for managing disk drives, printers, and other devices.

Utility program also performs specific task related to the management of computer functions, resources, password protection, memory management, virus protection, and file compression.

5 0
4 years ago
Other questions:
  • Critical Infrastructure and Key Resources (CIKR) are potential terrorist targets. CIKR might include: Select one: 1. All telecom
    14·1 answer
  • In Word, tables can be styled much like text can.<br> True<br> False
    6·1 answer
  • Each​ _____ in a relational database table is a unique record of something that users want to track.
    14·1 answer
  • Maya enjoys connectedWith her friends and social media apps but one of her friends post a lot of stuff that my thinks it’s annoy
    14·1 answer
  • 5. Create a vector called to20 that goes from 1 to 20 (use the range notation). Now create a variable called end that goes from
    9·1 answer
  • Which quality of service (QoS) mechanism provided by the network does real-time transport protocol (RTP) rely on to guarantee a
    13·1 answer
  • Why is drafting important in every industry
    6·1 answer
  • Asking questions when something is unclear is part of
    5·1 answer
  • Which of the following is considered a white collar crime?
    13·1 answer
  • 16 Select the correct answer. Rachel has set up a computer network. In this network, due to a device, the computers partake in t
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!