Added cycle counting and speed estimation
This commit is contained in:
parent
3462c7fb14
commit
c3d347d906
|
@ -5,3 +5,4 @@ emu816
|
||||||
/examples/simple/simple.obj
|
/examples/simple/simple.obj
|
||||||
/emu816.VC.VC.opendb
|
/emu816.VC.VC.opendb
|
||||||
/emu816.VC.db
|
/emu816.VC.db
|
||||||
|
/Release
|
||||||
|
|
|
@ -54,6 +54,7 @@ void emu816::reset(bool trace)
|
||||||
pc = mem.getWord(0xfffc);
|
pc = mem.getWord(0xfffc);
|
||||||
p.b = 0x34;
|
p.b = 0x34;
|
||||||
|
|
||||||
|
stopped = false;
|
||||||
interrupted = false;
|
interrupted = false;
|
||||||
|
|
||||||
this -> trace = trace;
|
this -> trace = trace;
|
||||||
|
@ -339,8 +340,6 @@ void emu816::step()
|
||||||
case 0xfe: op_inc(am_absx()); break;
|
case 0xfe: op_inc(am_absx()); break;
|
||||||
case 0xff: op_sbc(am_alnx()); break;
|
case 0xff: op_sbc(am_alnx()); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENDL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -478,6 +477,7 @@ void emu816::dump(const char *mnem, Addr ea)
|
||||||
// The current PC and opcode byte
|
// The current PC and opcode byte
|
||||||
void emu816::show()
|
void emu816::show()
|
||||||
{
|
{
|
||||||
|
cout << '{' << toHex(cycles, 4) << "} ";
|
||||||
cout << toHex(pbr, 2);
|
cout << toHex(pbr, 2);
|
||||||
cout << ':' << toHex(pc, 4);
|
cout << ':' << toHex(pc, 4);
|
||||||
cout << ' ' << toHex(mem.getByte(join(pbr, pc)), 2);
|
cout << ' ' << toHex(mem.getByte(join(pbr, pc)), 2);
|
||||||
|
@ -550,6 +550,6 @@ void emu816::dump(const char *mnem, Addr ea)
|
||||||
cout << ' ' << toHex(mem.getByte(sp.w + 3), 2);
|
cout << ' ' << toHex(mem.getByte(sp.w + 3), 2);
|
||||||
cout << ' ' << toHex(mem.getByte(sp.w + 4), 2);
|
cout << ' ' << toHex(mem.getByte(sp.w + 4), 2);
|
||||||
cout << " }";
|
cout << " }";
|
||||||
cout << " DBR=" << toHex(dbr, 2);
|
cout << " DBR=" << toHex(dbr, 2) << endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -1,7 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LocalDebuggerCommandArguments>-t examples\simple\simple.s28</LocalDebuggerCommandArguments>
|
<LocalDebuggerCommandArguments>-t examples/simple/simple.s28</LocalDebuggerCommandArguments>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LocalDebuggerCommandArguments>-t examples/simple/simple.s28</LocalDebuggerCommandArguments>
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
2
mem816.h
2
mem816.h
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
INLINE Addr getAddr(Addr ea)
|
INLINE Addr getAddr(Addr ea)
|
||||||
{
|
{
|
||||||
return (join(getByte(ea + 0), getWord(ea + 0)));
|
return (join(getByte(ea + 2), getWord(ea + 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void setByte(Addr ea, Byte data)
|
INLINE void setByte(Addr ea, Byte data)
|
||||||
|
|
27
program.cc
27
program.cc
|
@ -27,6 +27,8 @@ using namespace std;
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "Windows.h"
|
||||||
|
|
||||||
#include "mem816.h"
|
#include "mem816.h"
|
||||||
#include "emu816.h"
|
#include "emu816.h"
|
||||||
|
|
||||||
|
@ -148,8 +150,31 @@ int main(int argc, char **argv)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LARGE_INTEGER freq, start, end;
|
||||||
|
|
||||||
|
QueryPerformanceFrequency(&freq);
|
||||||
|
QueryPerformanceCounter(&start);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
for (;;) loop();
|
while (!emu.isStopped ())
|
||||||
|
loop();
|
||||||
|
|
||||||
|
QueryPerformanceCounter(&end);
|
||||||
|
|
||||||
|
double secs = (end.QuadPart - start.QuadPart) / (double) freq.QuadPart;
|
||||||
|
|
||||||
|
double speed = emu.getCycles() / secs;
|
||||||
|
|
||||||
|
cout << endl << "Overall CPU Frequency = ";
|
||||||
|
if (speed < 1000.0)
|
||||||
|
cout << speed << " Hz";
|
||||||
|
else {
|
||||||
|
if ((speed /= 1000.0) < 1000.0)
|
||||||
|
cout << speed << " KHz";
|
||||||
|
else
|
||||||
|
cout << (speed /= 1000.0) << " Mhz";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue