Added decimal mode (not tested) and corrected a bug or two

This commit is contained in:
andrew-jacobs 2016-11-01 23:13:54 +00:00
parent d7ffb289bb
commit ced9cfec50
3 changed files with 31 additions and 7 deletions

View File

@ -65,8 +65,8 @@ emu816::~emu816()
void emu816::reset(bool trace)
{
e = 1;
pbr = 0x00 << 16;
dbr = 0x00 << 16;
pbr = 0x00;
dbr = 0x00;
dp.w = 0x0000;
sp.w = 0x0100;
pc = getWord(0xfffc);
@ -495,7 +495,7 @@ void emu816::dump(const char *mnem, Addr ea)
// The current PC and opcode byte
void emu816::show()
{
cout << '{' << toHex(cycles, 4) << "} ";
// cout << '{' << toHex(cycles, 4) << "} ";
cout << toHex(pbr, 2);
cout << ':' << toHex(pc, 4);
cout << ' ' << toHex(getByte(join(pbr, pc)), 2);

View File

@ -26,7 +26,7 @@
#include <stdlib.h>
#if 0
#if 1
# define TRACE(MNEM) { if (trace) dump(MNEM, ea); }
# define BYTES(N) { if (trace) bytes(N); pc += N; }
# define SHOWPC() { if (trace) show(); }
@ -459,6 +459,11 @@ private:
if (e || p.f_m) {
Byte data = getByte(ea);
Word temp = a.b + data + p.f_c;
if (p.f_d) {
if ((temp & 0x0f) > 0x09) temp += 0x06;
if ((temp & 0xf0) > 0x90) temp += 0x60;
}
setc(temp & 0x100);
setv((~(a.b ^ data)) & (a.b ^ temp) & 0x80);
@ -469,7 +474,14 @@ private:
Word data = getWord(ea);
int temp = a.w + data + p.f_c;
setc(temp & 0x100);
if (p.f_d) {
if ((temp & 0x000f) > 0x0009) temp += 0x0006;
if ((temp & 0x00f0) > 0x0090) temp += 0x0060;
if ((temp & 0x0f00) > 0x0900) temp += 0x0600;
if ((temp & 0xf000) > 0x9000) temp += 0x6000;
}
setc(temp & 0x10000);
setv((~(a.w ^ data)) & (a.w ^ temp) & 0x8000);
setnz_w(a.w = (Word)temp);
cycles += 2;
@ -1443,6 +1455,11 @@ private:
if (e || p.f_m) {
Byte data = ~getByte(ea);
Word temp = a.b + data + p.f_c;
if (p.f_d) {
if ((temp & 0x0f) > 0x09) temp += 0x06;
if ((temp & 0xf0) > 0x90) temp += 0x60;
}
setc(temp & 0x100);
setv((~(a.b ^ data)) & (a.b ^ temp) & 0x80);
@ -1453,7 +1470,14 @@ private:
Word data = ~getWord(ea);
int temp = a.w + data + p.f_c;
setc(temp & 0x100);
if (p.f_d) {
if ((temp & 0x000f) > 0x0009) temp += 0x0006;
if ((temp & 0x00f0) > 0x0090) temp += 0x0060;
if ((temp & 0x0f00) > 0x0900) temp += 0x0600;
if ((temp & 0xf000) > 0x9000) temp += 0x6000;
}
setc(temp & 0x10000);
setv((~(a.w ^ data)) & (a.w ^ temp) & 0x8000);
setnz_w(a.w = (Word)temp);
cycles += 3;

View File

@ -1,7 +1,7 @@
<?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>examples/simple/simple.s28</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-t examples/simple/simple.s28</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">