object.c

来自「AVR反汇编,对ATMEGA8有效」· C语言 代码 · 共 69 行

C
69
字号
/*  Program: revava - Atmel Dis-Assembler  File: Object.C, Copyright (C) 2001 Daniel J. Winker  This program is free software; you can redistribute it and/or  modify it under the terms of the GNU General Public License  as published by the Free Software Foundation; either version 2  of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*/#include <stdio.h>//#include <strings.h>#include <string.h>#include "Error.h"#include "Flash.h"#include "IntelHex.h"#include "Object.h"#include "Source.h"TObjectIn::TObjectIn(const char* infile, TFlash* pFlash){	TIntelHexRecord HexRec;	FILE*           pf;	char            s[256];	// FIXME - Magic Number	char*           pc;	int             line = 0;	pf = fopen(infile, "r");	if( NULL == pf )		throw TFileError("Cannot open file:", infile);		try{		while( fgets( s, 256, pf ))		{			// Replace the newline with '\0'			//if( NULL != ( pc = rindex( s, '\n' )))			if( NULL != ( pc = strrchr( s, '\n' )))				*pc = '\0' ;			line++;			HexRec.StringToRecord( s );			if( 0 == HexRec.get_type())				pFlash->flashset(					HexRec.get_addr(),					HexRec.get_nbytes(),					HexRec.get_data());		}	}	catch ( TGenericError E ){		char msg[ 80 ];	// FIXME - Magic Number		sprintf( msg, "Error: File: %s, Line: %d\n", infile, line );		E.prepend_message( msg );		throw E ;	}	fclose(pf);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?