Ezasm for linux 1.0
Submitted By:
acvivek
Rating:
Not rated (
Rate It)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
void num_check(char a[],int word)
{
extern long int loc_ctr;
extern int line_count;
extern int err_count;
extern FILE *list_file;
FILE *inter = fopen("intr","a");
char *check(char [],int);
int i=0,j=0,z;
char str[30][30];
char num[30][30],tmp[30],b[30],x[30];
int flag=0,error=0,c=0,yes=0,count=0;
//checks for string const
if(a[i]=='"')
{
for(i=1;i<strlen(a);i++)
{
if(a[i]=='"')
{
yes=1;
break;
}
else
{
int l=a[i];
while(l>0)
{
int x=l%2;
b[j++]=x+48;
l=l/2;
}
b[j]='\0';
for(int k=strlen(b);k<8;k++)
b[j++]='0';
b[j]='\0';
j=0;
for(z=0;z<strlen(b);z++)
x[j++]=b[strlen(b)-z-1];
x[j]='\0';
j=0;
strcpy(b,x);
fflush(stdin);
strcpy(str[count++],b);
}
}
if(yes!=1)
{
printf("\nSyntax error at line (%d)",line_count);
err_count++;
}
else
{
for(i=0;i<count;i++)
{
fprintf(list_file,"\n%s",str[i]);
fprintf(inter,"%s",str[i]);
fprintf(list_file,"\tLoctr=%d",loc_ctr);
loc_ctr+=strlen(str[i])/8;
}
}
fclose(inter);
}
//check for array of numeric const
else if(isdigit(a[i]))
{
c=0;
for(i=0;i<strlen(a);i++)
{
if(isdigit(a[i]) || a[i]=='H' || a[i]=='h' || (a[i]>='A' && a[i]<='F') || (a[i]>='a' && a[i]<='f'))
{
tmp[j++]=a[i];
flag=0;
}
else if(a[i]==',')
{
tmp[j]='\0';
strcpy(num[c++],tmp);
flag=1;
j=0;
}
else if(a[i]==' ' ) flag=1;
else error=1;
}
if(flag==1) error=1;
else {tmp[j]='\0';strcpy(num[c++],tmp);}
if(error!=1)
{
for(i=0;i<c;i++)
strcpy(num[i],check(num[i],word));
for(i=0;i<c;i++)
{
fprintf(list_file,"\n%s",num[i]);
fprintf(list_file,"\tLoctr=%d",loc_ctr);
fprintf(inter,"%s",num[i]);
loc_ctr+=strlen(num[i])/8;
}
}
else
{
printf("\nSyntax error at line (%d)",line_count);
err_count++;
}
fclose(inter);
}
}