error while compiling

I was compiling a c++ program and it gives 2 errors:
1) expected ';' before '{' token
2) expected '}' at end of input.

But when I check the program all instructions have a ';' and i have also terminated all the functions with proper '}'

Can anyone please tell me wht are the other possibilities of mistake?
here is the function which supposedly has the first error:

int read_trace(FILE *fp,FILE *fp1,int add,int mult,int div,int load,int store,int clock)
{
char line[25];
static char instr[7];
static int not_issue=0;
static char dest_operand[4];
static char src1_operand[4];
static char src2_operand[4];
int src1_op,src2_op,dest_op;
int i=0,j=0;
int tag;

if(not_issue==1)
goto label;
//reading the instruction in a given line.
if(fgets(line,25,fp)!=NULL)
{
//Reading and storing the type of instr ADD or MULT etc.
while(line[i] != ' ')
instr[i]=line[i++];
instr[i]='\0';

while(line[i]==' ')
i++;
j=0;

//for add, mult and div
if(strcmp(instr,"LD")!=0 && strcmp(instr,"SD")!=0)
{
//Reading the destination operand.
while(line[i] != ' ')
dest_operand[j++]=line[i++];
dest_operand[j]='\0';

while(line[i]==' ')
i++;
j=0;

//Reading the first source operand.
while(line[i] != ' ' && line[i] != EOF && line[i] != '\n')
src1_operand[j++]=line[i++];
src1_operand[j]='\0';

while(line[i]==' ')
i++;
j=0;

//Reading the second source operand.
while(line[i] != ' ' && line[i] != EOF && line[i] != '\n')
src2_operand[j++]=line[i++];
src2_operand[j]='\0';

while(line[i]==' ')
i++;
j=0;
}
else //for LD and SD
{

//Reading the destination operand.
while(line[i] != ' ')
dest_operand[j++]=line[i++];
dest_operand[j]='\0';

while(line[i]==' ')
i++;
j=0;

//Reading the first source operand.
while(line[i] != ' ' && line[i] != EOF && line[i] != '\n')
src1_operand[j++]=line[i++];
src1_operand[j]='\0';

while(line[i]==' ')
i++;
j=0;

//assigning the second source operand to be Null
strcpy(src2_operand,"null");
}
fprintf(fp1,"instr: %s %s %s %s",instr,dest_operand,src1_operand,src2_operand);
label: dest_op = dest_operand[1]-48;
src1_op = src1_operand[1]-48;
src2_op = src2_operand[1]-48;
}

if(!strcmp(instr,"ADDD"))
{
tag=10;
if(issue_rs(add,add_rs,dest_op,src1_op,src2_op,ADDDCYCLE,tag,clock,add_pr))
{
add_stall+=1;
not_issue=1;
}
}

else if(!strcmp(instr,"MULD"))//SH:NOT SURE IF IT IS MULD OR MULTD, CHECK.
{
tag=20;
if(issue_rs(mult,mult_rs,dest_op,src1_op,src2_op,MULTDCYCLE,tag,clock,mult_pr))
{
mult_stall+=1;
not_issue=1;
}
}
else if(!strcmp(instr,"DIVD"))
{
tag=30;
if(issue_rs(div,div_rs,dest_op,src1_op,src2_op,DIVDCYCLE,tag,clock,div_pr))
{
div_stall+=1;
not_issue=1;
}
}
else if(!strcmp(instr,"LD"))
{
tag=40;
if(issue_rs(load,load_rs,dest_op,src1_op,src2_op,LOADCYCLE,tag,clock,ld_pr))
{
load_stall+=1;
not_issue=1;
}
}
else(!strcmp(instr,"SD"))
{
tag=50;
if(issue_rs(store,store_rs,dest_op,src1_op,src2_op,STORECYCLE,tag,clock,sd_pr))
{
store_stall+=1;
not_issue=1;
}
}
return 0;


else
return 1;
}
If you use [code][/code] tags and indent your code you may see where the error is

I'd say that the last part shows some if/else mismatch
1
2
3
4
5
6
7
8
9
10
11
12
13
    else(!strcmp(instr,"SD"))
    {
        tag=50;
        if(issue_rs(store,store_rs,dest_op,src1_op,src2_op,STORECYCLE,tag,clock,sd_pr))
        {
            store_stall+=1;
            not_issue=1;
        }
    }
    return 0;
    else // to which if?
    return 1;
} 
Topic archived. No new replies allowed.