Added cycle counting and speed estimation

This commit is contained in:
andrew-jacobs 2016-06-28 22:26:54 +01:00
parent 3462c7fb14
commit c3d347d906
6 changed files with 372 additions and 59 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ emu816
/examples/simple/simple.obj
/emu816.VC.VC.opendb
/emu816.VC.db
/Release

View File

@ -54,6 +54,7 @@ void emu816::reset(bool trace)
pc = mem.getWord(0xfffc);
p.b = 0x34;
stopped = false;
interrupted = false;
this -> trace = trace;
@ -339,8 +340,6 @@ void emu816::step()
case 0xfe: op_inc(am_absx()); 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
void emu816::show()
{
cout << '{' << toHex(cycles, 4) << "} ";
cout << toHex(pbr, 2);
cout << ':' << toHex(pc, 4);
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 + 4), 2);
cout << " }";
cout << " DBR=" << toHex(dbr, 2);
cout << " DBR=" << toHex(dbr, 2) << endl;
}
#endif

389
emu816.h

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>
</PropertyGroup>
</Project>

View File

@ -47,7 +47,7 @@ public:
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)

View File

@ -27,6 +27,8 @@ using namespace std;
#include <string.h>
#include "Windows.h"
#include "mem816.h"
#include "emu816.h"
@ -148,8 +150,31 @@ int main(int argc, char **argv)
return (1);
}
LARGE_INTEGER freq, start, end;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&start);
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);
}