foot/emulator/tests/test-common.h
shylie 80d83f2062
All checks were successful
Test / build (push) Successful in 13s
Add SIMD instruction variants
2025-08-17 11:18:08 -04:00

41 lines
726 B
C++

#include <foot-emulator.h>
#include <iostream>
inline foot::Emulator run_instruction(uint32_t instruction)
{
foot::Emulator emu;
emu.memory_at(0) = instruction;
emu.run_instruction();
return emu;
}
inline foot::Emulator run_instructions(const std::vector<uint32_t>& instructions)
{
foot::Emulator emu;
for (int i = 0; i < instructions.size(); i++)
{
emu.memory_at(i) = instructions[i];
}
for (int i = 0; i < instructions.size(); i++)
{
emu.run_instruction();
}
return emu;
}
inline bool check(uint32_t expected, uint32_t actual)
{
if (actual != expected)
{
std::cout << std::hex << "Expected " << expected << ", got " << actual << ".\n";
return false;
}
return true;
}