📄 intelhex.cpp
字号:
/*-----------------------------------------------------------------------------
6502 Macroassembler and Simulator
Copyright (C) 1995-2003 Michal Kowalski
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.
-----------------------------------------------------------------------------*/
// Odczyt i zapis kodu wynikowego w postaci Intel-HEX
#include "StdAfx.h"
#include "IntelHex.h"
#include "resource.h"
#include <TCHAR.h>
#include "MarkArea.h"
#include "Sym6502.h"
void CIntelHex::SaveHexFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int prog_start/*= -1*/)
{
TCHAR buf[80], *ptr;
for (UINT part=0; part<area.GetSize(); part++)
{
int start,end;
area.GetPartition(part,start,end);
ASSERT(start >= 0 && start <= 0xFFFF);
ASSERT(end >= 0 && end <= 0xFFFF);
ASSERT(start <= end);
const int STEP= 0x10;
for (int i=start; i<=end; i+=STEP)
{
int sum= 0; // suma kontrolna
int lim= min(i+STEP-1, end);
// pocz箃ek wiersza: ilo滄 danych, adres (hi, lo), zero
int cnt= i+STEP<=end ? STEP : end-i+1; // ilo滄 bajt體 do wys砤nia (w wierszu)
ptr = buf + wsprintf(buf,_T(":%02X%02X%02X%02X"),cnt,(i>>8)&0xFF,i&0xFF,0);
sum += cnt + ((i>>8)&0xFF) + (i&0xFF);
for (int j=i; j<=lim; j++)
{
ptr += wsprintf(ptr,_T("%02X"),mem[j]);
sum += mem[j];
} // suma wszystkich bajt體 w wierszu musi by
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -