pound-emu_pound/core/ARM/cpu.h
Ronald Caesar ba45834583
feat!: rewrote program in a data oriented style.
This is because the source code is objected oriented which is not cpu cache
friendly, making the program slower than it has to be. Yuzu's entire
codebase is written in a objected oriented way and I wonder how much faster
it could if they had use DoD principles from the very beginning.

That's why I want to instill DoD fundamentals early on so this won't be a
problem going forward.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-02 04:05:05 -04:00

49 lines
984 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2025 Pound Emulator Project. All rights reserved.
#pragma once
#include <cstring>
#include "Base/Logging/Log.h"
struct CPU
{
u64 regs[31] = {0}; // X0X30
u64 pc = 0;
static constexpr size_t MEM_SIZE = 64 * 1024;
u8 memory[MEM_SIZE];
CPU() { std::memset(memory, 0, MEM_SIZE); }
u64& x(int i) { return regs[i]; }
u8 read_byte(u64 addr)
{
if (addr >= MEM_SIZE)
{
LOG_INFO(ARM, "{} out of bounds", addr);
}
return memory[addr];
}
void write_byte(u64 addr, u8 byte)
{
if (addr >= MEM_SIZE)
{
LOG_INFO(ARM, "{} out of bounds", addr);
}
memory[addr] = byte;
}
void print_debug_information()
{
LOG_INFO(ARM, "PC = {}", pc);
for (int reg = 0; reg < 31; reg++)
{
uint64_t regis = x(reg);
LOG_INFO(ARM, "X{} = {}", reg, regis); // X0 = 0..
}
}
};
void cpuTest();