#include<math.h>
#include<stdio.h>
int split(int *c,int n)
{
int a,b,i,k=0,sum=0;
if(n==1)
{
a=0;b=1;
}
else
{
a=2;b=3;
}
for(i=b;i>=a;i--)
{
sum=sum+(c[i]*pow(2,k));
k++;
}
return(sum);
}
void binary(int sum,int *c)
{
int d,i=3,n;
n=sum;
while(n>0)
{
d=n%2;
c[i]=d;
n=n/2;
i--;
}
}
int main()
{
int a[10],k,i,j,n,temp1,temp2,b[10],c[4],d[32];
for(i=0;i<16;i++)
a[i]=i+65;
for(i=0;i<32;i++)
d[i]=32;
printf("\n\n how many values do u want to enter in page table:");
scanf("%d",&n);
printf("\n\n enter the page table\n\n");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
for(i=0;i<16;i++)
{
for(j=0;j<4;j++)
c[j]=0;
binary(i,&c[0]);
temp1=split(&c[0],1);
temp2=split(&c[0],3);
n=(b[temp1]*4)+temp2;
d[n]=i+65;
}
printf("\n\n\n\t\tpage table\n\n");
for(i=0;i<32;i++)
{
printf("\n address %d \t value %c",i,d[i]);
}
}
No comments:
Post a Comment