Compare commits
14 Commits
c2e22fb742
...
2f0c837464
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f0c837464 | |||
| f375b9c0ee | |||
| e265677727 | |||
| 59b6c70c3f | |||
| 0754d52d67 | |||
| b50e0a529d | |||
| 74b13b4d70 | |||
| 8c0b0bfc1b | |||
| 5024d45e58 | |||
| 83e3f5423f | |||
| bb54f0c15b | |||
| 634f6ff006 | |||
| f72110272d | |||
| 2230d4c662 |
+1
-1
@@ -169,7 +169,7 @@ void broadway::execute(ircolib::u32 instr, mem &mem) {
|
||||
std::println("broadway::execute unimplemented instruction 0x{:08X} / 0b{:032b}", instr, instr);
|
||||
std::println("disassembly:");
|
||||
print_disasm(instr);
|
||||
ircolib::panic("");
|
||||
ircolib::panic("LR: 0x{:08X}", lr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
#include <mem.hpp>
|
||||
|
||||
namespace weee::core {
|
||||
void broadway::add(ircolib::u32 instr) { gpr[utils::RD(instr)] = gpr[utils::RA(instr)] + gpr[utils::RB(instr)]; }
|
||||
void broadway::add(ircolib::u32 instr) {
|
||||
gpr[utils::RD(instr)] = gpr[utils::RA(instr)] + gpr[utils::RB(instr)];
|
||||
cr0_update(instr & 1, gpr[utils::RD(instr)]);
|
||||
}
|
||||
|
||||
void broadway::addi(ircolib::u32 instr) {
|
||||
if (utils::RA(instr) == 0) { // lis
|
||||
if (utils::RA(instr) == 0) { // li
|
||||
gpr[utils::RD(instr)] = ircolib::s32(utils::SIMM(instr));
|
||||
return;
|
||||
}
|
||||
@@ -145,12 +148,14 @@ void broadway::stwu(ircolib::u32 instr, mem &mem) {
|
||||
|
||||
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
|
||||
auto _ = mem.write32(EA, gpr[utils::RS(instr)])
|
||||
.and_then([&] { return std::expected<void, std::string>(); })
|
||||
.and_then([&] {
|
||||
gpr[utils::RA(instr)] = EA;
|
||||
return std::expected<void, std::string>();
|
||||
})
|
||||
.or_else([&](std::string e) {
|
||||
ircolib::panic("stwu broadway write failed. Reason: {} (pc: 0x{:08X})", e, pc - 4);
|
||||
return std::expected<void, std::string>();
|
||||
});
|
||||
gpr[utils::RA(instr)] = EA;
|
||||
}
|
||||
|
||||
void broadway::stbu(ircolib::u32 instr, mem &mem) {
|
||||
@@ -159,12 +164,14 @@ void broadway::stbu(ircolib::u32 instr, mem &mem) {
|
||||
|
||||
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
|
||||
auto _ = mem.write8(EA, gpr[utils::RS(instr)])
|
||||
.and_then([&] { return std::expected<void, std::string>(); })
|
||||
.and_then([&] {
|
||||
gpr[utils::RA(instr)] = EA;
|
||||
return std::expected<void, std::string>();
|
||||
})
|
||||
.or_else([&](std::string e) {
|
||||
ircolib::panic("stbu broadway write failed. Reason: {} (pc: 0x{:08X})", e, pc - 4);
|
||||
return std::expected<void, std::string>();
|
||||
});
|
||||
gpr[utils::RA(instr)] = EA;
|
||||
}
|
||||
|
||||
void broadway::stw(ircolib::u32 instr, mem &mem) {
|
||||
@@ -186,8 +193,7 @@ void broadway::sth(ircolib::u32 instr, mem &mem) {
|
||||
if (utils::RA(instr) == 0)
|
||||
b = 0;
|
||||
|
||||
const ircolib::s32 d = utils::SIMM(instr);
|
||||
const ircolib::u32 EA = b + d;
|
||||
const ircolib::u32 EA = b + utils::SIMM(instr);
|
||||
|
||||
auto _ = mem.write16(EA, ircolib::u16(gpr[utils::RS(instr)]))
|
||||
.and_then([&] { return std::expected<void, std::string>(); })
|
||||
@@ -219,16 +225,15 @@ void broadway::lfd(ircolib::u32 instr, mem &mem) {
|
||||
b = 0;
|
||||
|
||||
ircolib::u32 ea = ircolib::s32(b) + utils::SIMM(instr);
|
||||
double val;
|
||||
ircolib::u64 read = mem.read64(ea)
|
||||
|
||||
fgrs[utils::RD(instr)].ps0 =
|
||||
mem.read64(ea)
|
||||
.and_then([&](ircolib::u64 val) { return std::expected<ircolib::u64, std::string>(val); })
|
||||
.or_else([&](std::string e) {
|
||||
ircolib::panic("broadway read failed. Reason {} (pc: 0x{:08X})", e, pc - 4);
|
||||
return std::expected<ircolib::u64, std::string>();
|
||||
})
|
||||
.value();
|
||||
memcpy(&val, &read, 8);
|
||||
fgrs[utils::RD(instr)].ps0 = val;
|
||||
}
|
||||
|
||||
void broadway::bclrx(ircolib::u32 instr) {
|
||||
@@ -305,9 +310,15 @@ void broadway::rlwinm(ircolib::u32 instr) {
|
||||
ircolib::u32 r = std::rotl(gpr[utils::RS(instr)], sh);
|
||||
const ircolib::u8 mb = (instr >> 6) & 0x1f;
|
||||
const ircolib::u8 me = (instr >> 1) & 0x1f;
|
||||
const ircolib::u32 start = 0xffffffff >> mb;
|
||||
const ircolib::u32 end = 0x7fffffff >> me;
|
||||
ircolib::u32 mask = start ^ end;
|
||||
if (mb > me)
|
||||
mask = ~mask;
|
||||
|
||||
r &= ~((0xFFFF'FFFF >> mb) << me);
|
||||
r &= mask;
|
||||
gpr[utils::RA(instr)] = r;
|
||||
cr0_update(instr & 1, r);
|
||||
}
|
||||
|
||||
void broadway::lwzu(ircolib::u32 instr, mem &mem) {
|
||||
@@ -316,16 +327,21 @@ void broadway::lwzu(ircolib::u32 instr, mem &mem) {
|
||||
|
||||
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
|
||||
gpr[utils::RD(instr)] = mem.read32(EA)
|
||||
.and_then([&](ircolib::u32 val) { return std::expected<ircolib::u32, std::string>(val); })
|
||||
.and_then([&](ircolib::u32 val) {
|
||||
gpr[utils::RA(instr)] = EA;
|
||||
return std::expected<ircolib::u32, std::string>(val);
|
||||
})
|
||||
.or_else([&](std::string e) {
|
||||
ircolib::panic("broadway read failed. Reason {} (pc: 0x{:08X})", e, pc - 4);
|
||||
return std::expected<ircolib::u32, std::string>();
|
||||
})
|
||||
.value();
|
||||
gpr[utils::RA(instr)] = EA;
|
||||
}
|
||||
|
||||
void broadway::rfi(ircolib::u32 instr) { pc = srr0; }
|
||||
void broadway::rfi(ircolib::u32 instr) {
|
||||
pc = srr0;
|
||||
ircolib::clear_bit(msr, 13);
|
||||
}
|
||||
|
||||
void broadway::andi(ircolib::u32 instr) {
|
||||
const ircolib::s32 result = gpr[utils::RS(instr)] & utils::UIMM(instr);
|
||||
@@ -370,12 +386,12 @@ void broadway::nand(ircolib::u32 instr) {
|
||||
}
|
||||
|
||||
void broadway::subf(ircolib::u32 instr) {
|
||||
gpr[utils::RD(instr)] = ~(gpr[utils::RA(instr)] + gpr[utils::RB(instr)] + 1);
|
||||
gpr[utils::RD(instr)] = ~gpr[utils::RA(instr)] + gpr[utils::RB(instr)];
|
||||
cr0_update(instr & 1, gpr[utils::RD(instr)]);
|
||||
}
|
||||
|
||||
void broadway:: or (ircolib::u32 instr) {
|
||||
gpr[utils::RA(instr)] = gpr[utils::RS(instr)] & gpr[utils::RB(instr)];
|
||||
gpr[utils::RA(instr)] = gpr[utils::RS(instr)] | gpr[utils::RB(instr)];
|
||||
cr0_update(instr & 1, gpr[utils::RA(instr)]);
|
||||
}
|
||||
} // namespace weee::core
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <cstring>
|
||||
#include <mem.hpp>
|
||||
#include <ircolib/log.hpp>
|
||||
#include "ircolib/mem_access.hpp"
|
||||
#include <ircolib/mem_access.hpp>
|
||||
|
||||
namespace weee::core {
|
||||
mem::mem() : vi(*this) {
|
||||
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: true
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
IndentAccessModifiers: false
|
||||
AccessModifierOffset: 0
|
||||
ContinuationIndentWidth: 0
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*'
|
||||
Priority: 1
|
||||
- Regex: '^".*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentCaseBlocks: true
|
||||
InsertNewlineAtEOF: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
SortIncludes: Never
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: Inner
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
TabWidth: 4
|
||||
IndentWidth: 4
|
||||
...
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <ircolib/types.hpp>
|
||||
#include "types.hpp"
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
Vendored
+11
-11
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <cmath>
|
||||
#include <ircolib/types.hpp>
|
||||
#include "types.hpp"
|
||||
|
||||
namespace ircolib {
|
||||
static inline auto round_ceil(float f) {
|
||||
static inline auto roundCeil(float f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128 t = _mm_set_ss(f);
|
||||
t = _mm_round_ss(t, t, _MM_FROUND_TO_POS_INF);
|
||||
@@ -13,7 +13,7 @@ static inline auto round_ceil(float f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_ceil(double f) {
|
||||
static inline auto roundCeil(double f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128d t = _mm_set_sd(f);
|
||||
t = _mm_round_sd(t, t, _MM_FROUND_TO_POS_INF);
|
||||
@@ -23,7 +23,7 @@ static inline auto round_ceil(double f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_nearest(float f) {
|
||||
static inline auto roundNearest(float f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128 t = _mm_set_ss(f);
|
||||
t = _mm_round_ss(t, t, _MM_FROUND_TO_NEAREST_INT);
|
||||
@@ -33,7 +33,7 @@ static inline auto round_nearest(float f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_nearest(double f) {
|
||||
static inline auto roundNearest(double f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128d t = _mm_set_sd(f);
|
||||
t = _mm_round_sd(t, t, _MM_FROUND_TO_NEAREST_INT);
|
||||
@@ -43,7 +43,7 @@ static inline auto round_nearest(double f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_current(float f) {
|
||||
static inline auto roundCurrent(float f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
auto t = _mm_set_ss(f);
|
||||
t = _mm_round_ss(t, t, _MM_FROUND_CUR_DIRECTION);
|
||||
@@ -53,7 +53,7 @@ static inline auto round_current(float f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_current(double f) {
|
||||
static inline auto roundCurrent(double f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
auto t = _mm_set_sd(f);
|
||||
t = _mm_round_sd(t, t, _MM_FROUND_CUR_DIRECTION);
|
||||
@@ -64,7 +64,7 @@ static inline auto round_current(double f) {
|
||||
}
|
||||
|
||||
|
||||
static inline auto round_floor(float f) {
|
||||
static inline auto roundFloor(float f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128 t = _mm_set_ss(f);
|
||||
t = _mm_round_ss(t, t, _MM_FROUND_TO_NEG_INF);
|
||||
@@ -74,7 +74,7 @@ static inline auto round_floor(float f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_floor(double f) {
|
||||
static inline auto roundFloor(double f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128d t = _mm_set_sd(f);
|
||||
t = _mm_round_sd(t, t, _MM_FROUND_TO_NEG_INF);
|
||||
@@ -84,7 +84,7 @@ static inline auto round_floor(double f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_trunc(float f) {
|
||||
static inline auto roundTrunc(float f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128 t = _mm_set_ss(f);
|
||||
t = _mm_round_ss(t, t, _MM_FROUND_TO_ZERO);
|
||||
@@ -94,7 +94,7 @@ static inline auto round_trunc(float f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline auto round_trunc(double f) {
|
||||
static inline auto roundTrunc(double f) {
|
||||
#ifdef SIMD_SUPPORT
|
||||
__m128d t = _mm_set_sd(f);
|
||||
t = _mm_round_sd(t, t, _MM_FROUND_TO_ZERO);
|
||||
|
||||
Vendored
+2
-1
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <ircolib/types.hpp>
|
||||
#include "types.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <bit>
|
||||
|
||||
Vendored
+5
@@ -30,6 +30,11 @@ template <typename T>
|
||||
inline void set_bit(T &val, const std::size_t &bit) {
|
||||
val |= 1 << bit;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void clear_bit(T &val, const std::size_t &bit) {
|
||||
val &= ~(1 << bit);
|
||||
}
|
||||
} // namespace ircolib
|
||||
|
||||
constexpr ircolib::u32 operator""_kib(const unsigned long long v) { return v * 1024; }
|
||||
|
||||
Reference in New Issue
Block a user