4way LRU MIPS that mark the hits

Code for MIPS Mars



Code for implementation of this LRU MIPS
C language code
#include <stdio.h>
int findLRU(int time[],int n){
int i,min=time[0],pos = 0;
for(i=1;i<n;++i){
if (time[i]<min){
min=time[i];
pos=i;
}
}
return pos;
}
int main (){
int nf,np,frames[10],pages[30],counter=0,time[10],flag1,flag2,i,j,pos,faults=0;
printf ("enter num of frames");
scanf("%d",&nf);
printf("enter num of pages");
scanf("%d",&np);
printf ("enter the string");
for(i=0;i<np;++i)
scanf("%d",&pages[i]);
for(i=0;i<nf;++i)
frames[i]=-1;
for(i=0;i<np;++i){
flag1=flag2=0;
for(j=0;j<nf;++j){
if(frames[j]==pages[i]){
counter++;
time[j]=counter;
flag1=flag2 =1;
break;
}
}
if (flag1==0){
for(j=0;j<nf;++j){
if (frames[j]==-1){
counter++;
faults++;
frames[j]=pages[i];
time[j]=counter;
flag2=1;
break;
}
}
}
if (flag2 == 0){
pos=findLRU(time,nf);
counter++;
faults++;
frames[pos]=pages[i];
time[pos]=counter;
}
printf("\n");
for(j=0;j<nf;++j)
printf("%d\t",frames[j]);
}
}
printf("\n total number of page faults =%d",faults);
return 0;
}
MIPS (MARS CODE) Please covert this C++ code to MIPS code and leave comments on each line to what it does! int fib( int n ) { if ( n <= 1 ) return n; else return fib(n - 1 ) + fib( n - 2 ); }
Create a cache memory using mips in mars. The input of the simulator will be a file (or an array) with integers that represent a sequence of accesses to memory blocks. Each number represents a block of memory. The output of the simulator will be the number of hits for each cache configuration as well as the number of instructions executed. The results must be presented with the sequence of memory blocks delivered. While you are implementing your cache, you...
MIPS 1(a): Using MARS (MIPS assembly simulator), write and debug a program with comments that will store words in a RAM array using the instruction sw and indirect addressing as specified in the data table below. Although the addresses and data are in given hexadecimal, your code will contain corresponding values in decimal. Use (268501056)_10 = (10010040)_16 as the base address of the array. Since the instruction sw and indirect addressing (using offsets) are needed to store the data in...
IN MIPS MACHINE LANGUAGE FOR MARS SIMULATOR Write your own short program that presents a RAW data dependence condition (2-5 instructions in MIPS that exhibits a data hazard). Document the hazard condition in your code comments.
For the following program code, write MIPS pipeline execution diagram (mark stall if there are hazards). 2 1 11 : D ← C + 1 12 :D E
For the following program code, write MIPS pipeline execution diagram (mark stall if there are hazards). 2 1 11 : D ← C + 1 12 :D E
Objective Create a MIPS program in Mars to perform a sorting algorithm. Specification: 1) Download the file Assign2.asm. Read it and make sure it can be compiled and executed in Mars. 2) Write code to finish all the tasks listed in Assign2.asm. In Assign2.asm, an array‘a’ of ‘n’=11 integers are given at the beginning (make sure do not change these integers): 43, -5, 11, 12, 64, -7, 14, 71, 70, 13, -27 The finished Assign2.asm should be filled with your...
CONVERT THE FOLLOWING FUNCTION IN MARS SIMULATOR (MIPS) This FUNCTION should be Runnable on MARS (MIPS Assembler and Runtime Simulator) IDE C FUNCTION WHICH NEEDS TO BE CONVERTED (ONLY USE MARS) void decrypt(int numberOfChar, int key, char * cipherText, char * plainText) { int j = 0; int i =0; int k = 0; int reverseOrderedKey[4]; int n =4; int c =0; int d =0; int orderedKey[4] = {0,0,0,0}; while(key) { reverseOrderedKey[k] = key %10; key /= 10; k++; }...
using MIPS MARS sort an array of n integers and print both the sorted and unsorted array. n should be greater than or equal to 10 and entered by the user. Reminder make sure to use MIPS MARS only
Least Recently Used (LRU) is the most favorable replacement policy for direct mapped caches in MIPS architectures. True False L A Moving to another question will save this response. esc BO F2 FA # 3 $ % 5 2 4 6 w
using Mips assembly to work on Mars simulator write a program that outputs the maximum and minimum values of an entered array