-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15a9ec5
commit 3e0cbf0
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
|
||
void main(){ | ||
char icode[10][30],str[20],opr[10]; | ||
int i=0; | ||
printf("\n Enter the set of intermediate code (Terminated by exit): \n"); | ||
do{ | ||
scanf("%s",icode[i]); | ||
}while(strcmp(icode[i++],"exit")!=0); | ||
printf("\n \n Target code Generation"); | ||
printf("\n ********************"); | ||
i=0; | ||
do{ | ||
strcpy(str,icode[i]); | ||
switch(str[3]){ | ||
case '+':strcpy(opr,"ADD "); | ||
break; | ||
case '-':strcpy(opr,"SUB "); | ||
break; | ||
case '*':strcpy(opr,"MUL "); | ||
break; | ||
case '/':strcpy(opr,"DIV "); | ||
break; | ||
} | ||
|
||
|
||
printf("\n\tMOV %c,R%d\n",str[2],i); | ||
printf("\n\t%s%c,R%d\n",opr,str[4],i); | ||
printf("\n\tMOV R%d,%c\n",i,str[0]); | ||
}while(strcmp(icode[++i],"exit")!=0); | ||
|
||
} |