Beispiel #1
0
void oprconvert2add(char oprout[], char oprin[]){ //Find address of registers in 2 addresable instructions
	int i,j,k,num,x,num1,num2,flag1,flag2;
	char temp1[105],temp2[105];
	j=0;
	k=0;
	x=1;
	flag1=flag2=0;
	for(i=0;i<strlen(oprin);i++){
		if((oprin[i]=='R' || oprin[i]=='F') && x==1){
			j=0;
			if(oprin[i]=='F')
			flag1=1;
			i++;
			while(oprin[i]!=' ' && oprin[i]!=','){
				temp1[j++]=oprin[i];
				i++;
			}
			temp1[j]='\0';
			x++;
		}
	
		if((oprin[i]=='R' || oprin[i]=='F')&& x==2){
			j=0;
			i++;
			if(oprin[i]=='F')
			flag2=1;
			while(oprin[i]!=' ' && oprin[i]!=',' && oprin[i]){
				temp2[j++]=oprin[i];
				i++;
			}
			temp2[j]='\0';

			x++;
		}	
	}
	num1=convNum(temp1);
	num2=convNum(temp2);
	if(flag1)
	num1 +=9;
	if(flag2)
	num2 +=9;
	
	getbin(num1,temp1);
	getbin(num2,temp2);
	for(k=0;temp1[k];){
		oprout[k++]= temp1[k];
	}
	for(i=0;temp2[i];i++){
		oprout[k++]= temp2[i];
	}
	
	oprout[k] = '\0';
}
Beispiel #2
0
void oprconvert1add(char oprout[], char oprin[]){  //Find address of registers in 1 addresable instructions
	int i,j,k,num1;
	char temp1[105];
	j=0;
	k=0;
	for(i=0;i<strlen(oprin);i++){
		
		if(oprin[i]=='R'){
			j=0;
			i++;
			while(oprin[i]!=' ' && oprin[i]!=',' && oprin[i]){
				temp1[j++]=oprin[i];
				i++;
			}
			temp1[j]='\0';
		}	
	}
	num1=convNum(temp1);
	getbin(num1,temp1);
	for(k=0;temp1[k];){
		oprout[k++]= temp1[k];
	}
	
	oprout[k] = '\0';
}
Beispiel #3
0
int noOfRegistersI(int count,char tempoprin[])
{

			char temp[35];
			char imm[105];
			int i,status=1,j,data,flag;
				
				for(i=0;i<strlen(tempoprin);i++)
				{
					while(tempoprin[i]==' ')
					i++;
					if(tempoprin[i]==82 || tempoprin[i]==70)
					count--;
					else
					{
						printf("Invalid registers\n");
						return 0 ;
					}
					j=0;
					i++;
					while(tempoprin[i]!=',')
					{
						temp[j++]=tempoprin[i];
						i++;
					}
					temp[j]='\0';
					if(count>0)
					status=checkComma(temp);
					while(tempoprin[i]!='\0' && count==0)
					{
						flag=1;
						if(tempoprin[i]>=48 && tempoprin[i]<=57)
						imm[j++]=tempoprin[i];
						else
							flag=0;
						i++;
					}
					imm[j]='\0';
					if(count==0){
						if(flag)
						data=convNum(imm)%65535;
						else{
							printf("Invalid Data\n");
							return 0;
						}
						
					}
				}
				if(count!=0)
				{
					printf("Invalid No. of registers\n");
					return 0;
				}
			
	return status;
}
Beispiel #4
0
void oprconvimmid12(char oprout[], char oprin[]){ //Find address of registers in 2 addresable instructions with imm data
		int i,j,k,num,x,num1,num2;
	char temp1[105],temp2[105];
	j=0;
	k=0;
	x=1;
	for(i=0;i<strlen(oprin);i++){
		if(oprin[i]=='R' && x==1){
			j=0;
			i++;
			while(oprin[i]!=' ' && oprin[i]!=','){
				temp1[j++]=oprin[i];
				i++;
			}
			temp1[j]='\0';
			x++;
		}
	
		if(oprin[i]>=48 && oprin[i]<=57 && x==2){
			j=0;
			while(oprin[i]!=' ' && oprin[i]!=',' && oprin[i]){
				temp2[j++]=oprin[i];
				i++;
			}
			temp2[j]='\0';

			x++;
		}	
	}
	num1=convNum(temp1);
	num2=convNum(temp2);
	getbin(num1,temp1);
	getAddress(num2,temp2);
	for(k=0;temp1[k];){
		oprout[k++]= temp1[k];
	}
	for(i=0;temp2[i];i++){
		oprout[k++]= temp2[i];
	}
	
	oprout[k] = '\0';	
}
Beispiel #5
0
void jumpCall(char oprout[], char oprin[],char lab[][55],int labadd[],char tempoprin[]){
	int i,adr;
	char temp[17];
	
	if(tempoprin[0]=='J' || tempoprin[0]=='C'){
			adr=labSearch(lab,oprin);
	}
	else{
		adr=convNum(oprin);
	}
	
	getAddress(adr,temp);
	strcpy(oprout,temp);

}
Beispiel #6
0
void oprconvimmid8(char oprout[], char oprin[]){  //Find address of registers in 3 addresable instructions with immd data
		int i,j,k,num,x,num1,num2,num3,flag;
	char temp1[105],temp2[105],temp3[105],comp[105];
	j=0;
	k=0;
	x=1;
	flag=0;
	for(i=0;i<strlen(oprin);i++){
		if(oprin[i]=='R' && x==1){
			j=0;
			i++;
			while(oprin[i]!=' ' && oprin[i]!=','){
				temp1[j++]=oprin[i];
				i++;
			}
			temp1[j]='\0';
			x++;
		}
		if(oprin[i]=='R' && x==2){
			j=0;
			i++;
			while(oprin[i]!=' ' && oprin[i]!=','){
				temp2[j++]=oprin[i];
				i++;
			}
			temp2[j]='\0';
			x++;
		}
		if(((oprin[i]>=48 && oprin[i]<=57 ) || oprin[i]=='-') && x==3){
			j=0;
			while(oprin[i]){
				
				if(oprin[i]=='-')
				flag=1;
				else
				temp3[j++]=oprin[i];
				

				i++;
			}
			temp3[j]='\0';

			x++;
		}	
	}
	
	
	num1=convNum(temp1);
	num2=convNum(temp2);
	num3=convNum(temp3);
	getbin(num1,temp1);
	getbin(num2,temp2);
	getAddress(num3,temp3);
	if(flag)
	twosCompl(temp3,comp);


	for(k=0;temp1[k];){
		oprout[k++]= temp1[k];
	}
	for(i=0;temp2[i];i++){
		oprout[k++]= temp2[i];
	}
	if(flag==0){
	
		for(i=0;temp3[i];i++){
			oprout[k++]= temp3[i];
		}
	}
	else{
			for(i=0;comp[i];i++){
			oprout[k++]= comp[i];
		}
	}
	oprout[k] = '\0';
}