SIMPLIFIED INSTRUCTIONAL COMPUTER


/**************************************************************

(THIS PROGRAMM IS UNDER CONSTRUCTION)

-> This program is to simulate the working of
SIMPLIFIED INSTRUCTIONAL COMPUTER

**************************************************************/

#include<iostream.h>

class sic
{
private:
int a[32768];
int A,X,L,PC,SW;
public:
void simulate();
};

void sic::simulate()
{
A=0;
cout<<”MENU :\n”<<”1.Programm mode\n”<<”2.Interface mode\n3.Exit\n”;
cout<<”Enter your option”;
int option;
cin>>option;
while(option!=3)
{
if(option==1)
{
cout<<”Enter the starting address ::”;
int i;
cin>>i;
int l=i;
cout<<”SIC :>”;
int byte;
cin>>byte;
while(byte!=0)
{
a[i]=byte;
i++;
cout<<”SIC :>”;
cin>>byte;
}
a[i]=0;
cout<<”The entered programm is :\n”;
while(l<i)
cout<<a[l++]<<’\n’;
}
else if (option==2)
{
cout<<”Enter the command :”;
int start,end;char programm[20];
cin>>programm>>start>>end;
a[20]=20;
a[21]=10;
for(int c=start;c<=end;c++)
{
int n=a[c];
switch(n)
{
/****** Instructions that load the registers ******/
case 00:
// A <- (m..m+2)
A = ( (a[m]<<4 + a[m+1]) <<4 ) +a[m+2];
break;
case 50:
// A[Right most byte] <- (m)
A = a[m+2];
break;
case 08:
// L <- (m..m+2)
L = ( (a[m]<<4 + a[m+1]) <<4 ) +a[m+2];
break;
case 04:
// X <- (m..m+2)
X = ( (a[m]<<4 + a[m+1]) <<4 ) +a[m+2];
break;

/****** Instructions that stote the registers ******/
case 00:
// A <- (m..m+2)
A = ( (a[m]<<4 + a[m+1]) <<4 ) +a[m+2];
break;
case 50:
// A[Right most byte] <- (m)
A = a[m+2];
break;
case 08:
// L <- (m..m+2)
L = ( (a[m]<<4 + a[m+1]) <<4 ) +a[m+2];
break;
case 04:
// X <- (m..m+2)
X = ( (a[m]<<4 + a[m+1]) <<4 ) +a[m+2];
break;
case 18: // ADD m
A=A+a[a[c+1]]*100+a[a[c+1]+1];
c+=2;
break;
case 90: // ADDR r1,r2
r2=r2+r1;
break;
case 40: // AND m
A=A&( a[a[c+1]]*100+a[a[c+1]+1]) ;
break;
case b4: // CLEAR r1
r1=0;
break;
case 28: // COMP m
if(A > ( a[a[c+1]]*100+a[a[c+1]+1] ) )
CC= ‘>’;
else if( A< ( a[a[c+1]]*100+a[a[c+1]+1] ))
CC=’<’;
else
CC=’=’;
break;
case a0: // COMP r1,r2
if(r1 >r2)
CC = ‘>’;
else if(r1<r2)
CC = ‘<’;
else
CC = ‘=’;
break;
case 24: // DIV m
A/=(a[a[c+1]]*100+a[a[c+1]+1]);
break;
case 9c: // DIV r1,r2
r2=r2/r1;
break;
case f4:
// Halt I/O Channel
break;
case 3c: // J m
PC=a[a[c+1]];
break;
case 30: // JEQ m
if( CC= ‘=’)
PC = a[a[c+1]];
break;
case 34: // JGT m
if( CC= ‘>’)
PC = a[a[c+1]];
break;
case 38: // JLT m
if( CC=’<’ )
PC = a[a[c+1]];
break;
case 48: //
}
}
}
else
return;
cin>>option;
}
}

int main()
{
sic computer;
computer.simulate();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s