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
Can someone write a 5 sentence summary about Virtual Assistants. Please. I'm in a rush. Personal problems.
Lyrx [107]
Virtual Assistants can be useful. Blind people can use them to be informed, browse the web, and learn new facts. They can make tasks quicker too. They can control things like your heater or air conditioner. But if one were to malfunction, it could take lives.
7 0
3 years ago
What underlying concept is edge computing based on?
guajiro [1.7K]

Answer:

Edge computing was developed due to the exponential growth of IoT devices, which connect to the internet for either receiving information from the cloud or delivering data back to the cloud. And many IoT devices generate enormous amounts of data during the course of their operations.

Explanation:

8 0
2 years ago
Read 2 more answers
Sidney works in the accounting department. His boss just assigned him a task that involves creating budget formulas for the comp
madreJ [45]
In excel spreadsheets, Sidney need to consider specifying relationships between the information you have stored in your spreadsheets when creating formulas. The elements that will help you understand using spreadsheet are the constants, operators, references and functions. This will enable her to use the formulas, without hassle in spreadsheets.
6 0
2 years ago
A copy of the copyrighted work must be exactly the same as the original to infringe a copyright.
nordsb [41]

Answer:

true

Explanation:

7 0
3 years ago
Describe one difference and one similarity between science and pseudoscience.
irakobra [83]
A scientific experiment is repeatable. Pseudoscience makes claims that cannot be either confirmed or denied. Both seem to want to explain our experiences and broaden our understanding. Science, as a working method, employs basic principles such as objectivity and accuracy to establish a finding. It often also uses certain admitted assumptions about reality, assumptions that must eventually support themselves and be proven, or the resulting finding fails verification. Pseudoscience, however, uses invented modes of analysis which it pretends or professes meet the requirements of scientific method, but which in fact violate it's essential attributes. Many obvious examples of pseudoscience are easy to identify, but the more subtile and herefore more insidious and convincing cases.
6 0
3 years ago
Other questions:
  • What allows multiple computers to join the same network
    11·1 answer
  • The overall purpose of a food guide is________.
    11·1 answer
  • the piece of hardware that contains the circuitry that processes the information coming in to the computer
    13·1 answer
  • Who created apple and in what year was it created
    9·2 answers
  • Betty set up an account on a popular social networking website. she wants to know whether the privacy policy is effective for he
    14·1 answer
  • Label provides the code that executes if no case label is matched ​
    6·1 answer
  • 7. Which cipher is based on the clues of the physical factors, rather than the hardware or a software cryptosystem
    8·1 answer
  • What is the next line?
    7·1 answer
  • A human subject’s photographs show two catchlights in each eye that are unwanted by the photographer. What is the most likely ca
    12·1 answer
  • What would be the best tool to display the following information from a basketball game?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!