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]
2 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]2 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
The _____ option will require users to have a password to access the document.
Zepler [3.9K]
The login option will require users to have to have a password to access the document
6 0
3 years ago
Read 2 more answers
Which tools are found in the Quick Analysis feature? Check all that apply.
a_sh-v [17]

Answer:

A, C, E

Explanation:

8 0
3 years ago
Read 2 more answers
I'm making a game. I'm trying to make it so that instead of how I currently have it, starting whenever I click the screen, it st
Lera25 [3.4K]
That’s cool I’ll play the game tonight if I can
6 0
2 years ago
Keith has to carry out a photo shoot to capture images of the ocean during the monsoons. What is a recommended practice when sho
Semmy [17]

Answer:

Answer is A: place absorbent chemical packets in the camera cover

Explanation:

Keith is required to carry adequate gear while going for a shoot. And in this case, he should carry anything that will protect his camera from the ocean and rainwater. By anything, I mean anything that Keith will use to stay dry. Using an air conditioner would be the worst idea. An air conditioner might blow the air towards your camera. Placing the camera in its case will ensure that it is dry and Keith will keep on shooting. Placing absorbent chemical packets in the camera cover will ensure that any water droplets that might fall on the cover of the camera will be absorbed. The point here is to keep dry.

6 0
3 years ago
Which describes the third step in visual character development
allsm [11]

I would say 3-D model!!!! not 100% sure but this sounds most correct!

5 0
2 years ago
Read 2 more answers
Other questions:
  • An administrator running a port scan wants to ensure that no processes are listening on port 23. What state should the port be i
    7·1 answer
  • 6.
    14·2 answers
  • Fortnite anyone? i just started tdy so dont be judgiee lol
    6·2 answers
  • Which of the following browsers was introduced with windows 10?
    10·1 answer
  • An organization is developing an authentication service for use at the entry and exit ports of country borders. The service will
    10·1 answer
  • Genetics Vocabulary: no <br> Allele: Different versions of the same qene (Aa, Bb)
    11·1 answer
  • Avi does not want to save his internet browsing details on his computer. What should he do?
    11·1 answer
  • Which of the following is NOT an algorithm?
    15·1 answer
  • Which is NOT true?<br> 9 + 4 = 17 - 4<br> 8 + 7 = 14 + 3<br> 11 = 19 - 8<br> 5 + 8 = 20 - 7
    9·1 answer
  • What is a good theme statement for the short Pixar film "bao"?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!