/
runcommandassemble.cpp
87 lines (79 loc) · 2.13 KB
/
runcommandassemble.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
#include <assert.h>
#include "hexconv.h"
#include "boost2005.h"
#include "bits.h"
#include "mlist.h"
#include "carray.h"
#include "defines.h"
#include "cevent.h"
#include "bits.h"
#include "util.h"
#include "StringConverter.h"
#include "ErrorLogger.h"
#include "errormsg.h"
#include "hconfig.h"
#include "appstatus.h"
#include "register.h"
#include "savestate.h"
#include "c6502.h"
#include "assembler.h"
#include "runcommand.h"
#include "commandresult.h"
#include "monitor.h"
RunCommandAssemble::RunCommandAssemble(ICommandResult *pCommandResult, DBGSYM::CliCpuMode::CliCpuMode cpumode, int iDebuggerMmuIndex, bit16 startaddress, bit8 *data, int dataLength)
{
this->m_pCommandResult = pCommandResult;
this->m_cpumode = cpumode;
this->m_iDebuggerMmuIndex = iDebuggerMmuIndex;
this->m_startaddress = startaddress;
this->m_address = startaddress;
this->m_data = data;
this->m_dataLength = dataLength;
this->m_sLineBuffer.reserve(50);
}
HRESULT RunCommandAssemble::Run()
{
WriteBytesToMemory(m_startaddress, m_data, m_dataLength);
return S_OK;
}
void RunCommandAssemble::WriteBytesToMemory(bit16 startaddress, bit8 *buffer, int dataLength)
{
TCHAR addressText[10];
std::basic_string<TCHAR> s;
s.reserve(20);
IMonitor *pMon = m_pCommandResult->GetMonitor();
IMonitorCpu *pCpu;
if (m_cpumode == DBGSYM::CliCpuMode::C64)
{
pCpu = pMon->GetMainCpu();
}
else
{
pCpu = pMon->GetDiskCpu();
}
if (dataLength > 0)
{
for(int i = 0; i<dataLength; i++)
{
pCpu->MonWriteByte((bit16)(startaddress + i), buffer[i], m_iDebuggerMmuIndex);
}
bit16 nextaddress = (bit16)(startaddress + dataLength);
if (pMon->Get_Radix() == DBGSYM::MonitorOption::Dec)
{
s.append(TEXT("A ."));
_sntprintf_s(addressText, _countof(addressText), _TRUNCATE, TEXT("%-d"), (unsigned int)nextaddress);
}
else
{
s.append(TEXT("A $"));
HexConv<TCHAR>::long_to_hex(nextaddress, addressText, 4);
}
s.append(addressText);
s.append(TEXT(" "));
m_pCommandResult->AddLine(s.c_str());
}
}