Tidy some more Windows/Linux compatibility issues.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-09-03 21:30:46 +01:00
parent c55bba5d2b
commit da806bddcb
7 changed files with 29 additions and 40 deletions

View File

@ -46,8 +46,6 @@ namespace EightBit {
register16_t hl;
uint8_t R(int r) {
__assume(r < 8);
__assume(r >= 0);
switch (r) {
case 0b000:
return B();
@ -66,14 +64,12 @@ namespace EightBit {
case 0b111:
return A();
default:
__assume(0);
UNREACHABLE;
}
throw std::logic_error("Unhandled registry mechanism");
}
void R(int r, uint8_t value) {
__assume(r < 8);
__assume(r >= 0);
switch (r) {
case 0b000:
B() = value;
@ -100,13 +96,11 @@ namespace EightBit {
A() = value;
break;
default:
__assume(0);
UNREACHABLE;
}
}
register16_t& RP(int rp) {
__assume(rp < 4);
__assume(rp >= 0);
switch (rp) {
case 0b00:
return BC();
@ -117,13 +111,11 @@ namespace EightBit {
case 0b11:
return SP();
default:
__assume(0);
UNREACHABLE;
}
}
register16_t& RP2(int rp) {
__assume(rp < 4);
__assume(rp >= 0);
switch (rp) {
case 0b00:
return BC();
@ -134,7 +126,7 @@ namespace EightBit {
case 0b11:
return AF();
default:
__assume(0);
UNREACHABLE;
}
}

View File

@ -57,7 +57,7 @@ bool EightBit::Intel8080::jumpConditionalFlag(uint8_t& f, int flag) {
case 7: // M
return jumpConditional(f & SF);
default:
__assume(0);
UNREACHABLE;
}
throw std::logic_error("Unhandled JP conditional");
}
@ -81,7 +81,7 @@ bool EightBit::Intel8080::returnConditionalFlag(uint8_t& f, int flag) {
case 7: // M
return returnConditional(f & SF);
default:
__assume(0);
UNREACHABLE;
}
throw std::logic_error("Unhandled RET conditional");
}
@ -105,7 +105,7 @@ bool EightBit::Intel8080::callConditionalFlag(uint8_t& f, int flag) {
case 7: // M
return callConditional(f & SF);
default:
__assume(0);
UNREACHABLE;
}
throw std::logic_error("Unhandled CALL conditional");
}
@ -317,7 +317,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
cycles += 13;
break;
default:
__assume(0);
UNREACHABLE;
}
break;
case 1:
@ -346,11 +346,11 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
cycles += 13;
break;
default:
__assume(0);
UNREACHABLE;
}
break;
default:
__assume(0);
UNREACHABLE;
}
break;
case 3: // 16-bit INC/DEC
@ -362,7 +362,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
--RP(p).word;
break;
default:
__assume(0);
UNREACHABLE;
}
cycles += 6;
break;
@ -413,12 +413,12 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
cmc(a, f);
break;
default:
__assume(0);
UNREACHABLE;
}
cycles += 4;
break;
default:
__assume(0);
UNREACHABLE;
}
break;
case 1: // 8-bit loading
@ -458,7 +458,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
compare(f, a, R(z));
break;
default:
__assume(0);
UNREACHABLE;
}
cycles += 4;
if (z == 6)
@ -494,7 +494,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
}
break;
default:
__assume(0);
UNREACHABLE;
}
break;
case 2: // Conditional jump
@ -555,7 +555,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
}
break;
default:
__assume(0);
UNREACHABLE;
}
break;
case 6: // Operate on accumulator and immediate operand: alu[y] n
@ -585,7 +585,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
compare(f, a, fetchByte());
break;
default:
__assume(0);
UNREACHABLE;
}
cycles += 7;
break;
@ -594,7 +594,7 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
cycles += 11;
break;
default:
__assume(0);
UNREACHABLE;
}
break;
}

View File

@ -1,6 +1,4 @@
#ifdef _MSC_VER
#pragma once
#endif
#include <cstdint>
#include <functional>

View File

@ -98,19 +98,16 @@ namespace EightBit {
//
static int buildHalfCarryIndex(uint8_t before, uint8_t value, int calculation) {
__assume(calculation < 0x1ffff);
return ((before & 0x88) >> 1) | ((value & 0x88) >> 2) | ((calculation & 0x88) >> 3);
}
static bool calculateHalfCarryAdd(uint8_t before, uint8_t value, int calculation) {
__assume(calculation < 0x1ffff);
static std::array<bool, 8> m_halfCarryTableAdd = { { false, false, true, false, true, false, true, true } };
auto index = buildHalfCarryIndex(before, value, calculation);
return m_halfCarryTableAdd[index & Mask3];
}
static bool calculateHalfCarrySub(uint8_t before, uint8_t value, int calculation) {
__assume(calculation < 0x1ffff);
std::array<bool, 8> m_halfCarryTableSub = { { false, true, true, true, false, false, false, true } };
auto index = buildHalfCarryIndex(before, value, calculation);
return m_halfCarryTableSub[index & Mask3];

View File

@ -4,9 +4,13 @@
#include "Memory.h"
#ifdef _MSC_VER
# define UNREACHABLE __assume(0)
#endif
#ifdef __GNUG__
# define __assume(cond) do { if (!(cond)) __builtin_unreachable(); } while (0)
# define __popcnt __builtin_popcount
# define UNREACHABLE __builtin_unreachable();
#endif
namespace EightBit {

View File

@ -4,10 +4,10 @@
#include <chrono>
#include <iostream>
#ifdef __GNUG__
#include <x86intrin.h>
#else
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
namespace EightBit {

View File

@ -1,6 +1,4 @@
#ifdef _MSC_VER
#pragma once
#endif
#include <cstdint>
#include <functional>
@ -14,8 +12,8 @@
#include <array>
#include <vector>
#ifdef __GNUG__
#include <x86intrin.h>
#else
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <x86intrin.h>
#endif