Skip to content

Commit

Permalink
new update
Browse files Browse the repository at this point in the history
  • Loading branch information
arjundastp committed Dec 16, 2023
1 parent 15a9ec5 commit 3e0cbf0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Binary file added compilerbackend/a.out
Binary file not shown.
33 changes: 33 additions & 0 deletions compilerbackend/backend.c
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);

}

0 comments on commit 3e0cbf0

Please sign in to comment.