void Assembler :: pass2(ifstream &inHandle, ofstream &outHandle)
{	outHandle<<setfill('0');
	while(!inHandle.eof())
	{	inHandle.getline(src_line,50);
		//declerative or imperative statement
		if(toascii(src_line[0])>=48 && toascii(src_line[0])<=57)
		{	breakStatement();
			outHandle<<address<<")\t+ "<<mnemonicCode<<" "<<regCode<<" "<<setw(3)<<operand<<"\n";
		}
		else
			outHandle<<"\n";
	}
}

void Assembler :: breakStatement()
{	int i=0,j=0;
	char oprCode[20],oprClass;
	ifstream in;
	
	//initializing all variables
	strcpy(address,NULL);
	strcpy(mnemonicClass,NULL);
	strcpy(mnemonicCode,NULL);
	init(oprCode);
	regCode='0';
	operand=0;
	
	//get line address
	while(src_line[i]!=')')
		address[i]=src_line[i++];
		
	//find mnemonic class string at i-2,i-1
	while(src_line[i]!=',')
		i++;
	
	//post-LTORG or post-END literal statement	
	if(src_line[i-2]=='(' && src_line[i-1]=='L')
	{	//set mnemonic code
		strcpy(mnemonicCode,"00");
		//keep register code as default 0
		
		//get operand
		i++;
		while(src_line[i]!=')')
			oprCode[j++]=src_line[i++];
		cout<<"\n"<<oprCode;
		operand=getOperandAddress(oprCode,'L',in);
	}
	in.close();
	
        return;
	cout<<"check";
	
}

This is part of my code for pass2 of a two-pass assembler
I get an error saying
"Abnormal program termination"
whenever the control reaches the return statement, no matter where i place the return statement i get the same error.

any idea why this is happening ??

Recommended Answers

All 2 Replies

>>strcpy(address,NULL);

strcpy() hates that statement because it expects a valid pointer as the second argument, not NULL pointer. If all you want to do is initialize the array to 0 then use memset(), e.g. memset(address,0,sizeof(address)); , assuming that address is not a pointer. Or you can just simply do this: address[0] = 0;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.