mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-12 10:37:00 +00:00
Added Makefile and made things run on my machine (im sorry ); )
This commit is contained in:
parent
c8f00d0657
commit
8bdd9468de
4 changed files with 51 additions and 16 deletions
29
Makefile
Normal file
29
Makefile
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
CXX := g++
|
||||||
|
CXXFLAGS := -std=c++17 -Wall -Wextra -Icore -Icore/ARM -Icore/audio -Icore/fs -Icore/gpu/emu -Icore/gpu/vk -Icore/JIT
|
||||||
|
|
||||||
|
SRC := \
|
||||||
|
ui/main.cpp \
|
||||||
|
core/audio/audio.cpp \
|
||||||
|
core/fs/fs.cpp \
|
||||||
|
core/gpu/emu/emugpu.cpp \
|
||||||
|
core/gpu/vk/emugpuvk.cpp \
|
||||||
|
core/JIT/jit.cpp
|
||||||
|
|
||||||
|
OBJ := $(SRC:.cpp=.o)
|
||||||
|
TARGET := app
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJ)
|
||||||
|
$(CXX) $(OBJ) -o $(TARGET)
|
||||||
|
|
||||||
|
%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJ) $(TARGET)
|
||||||
|
|
||||||
|
run: $(TARGET)
|
||||||
|
./$(TARGET)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
@ -1,18 +1,20 @@
|
||||||
#include "core/JIT/jit.h"
|
#include "jit.h"
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using JitFunc = void(*)();
|
using JitFunc = void (*)();
|
||||||
|
|
||||||
void JIT::translate_and_run(CPU& cpu) {
|
void JIT::translate_and_run(CPU &cpu)
|
||||||
uint8_t* code = (uint8_t*)mmap(nullptr, 64, PROT_READ | PROT_WRITE | PROT_EXEC,
|
{
|
||||||
MAP_PRIVATE | MAP_ANON, -1, 0);
|
uint8_t *code = (uint8_t *)mmap(nullptr, 64, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
|
MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
// Decode mock instructions from cpu.memory
|
// Decode mock instructions from cpu.memory
|
||||||
if (cpu.memory[0] == 0x05) { // MOVZ placeholder
|
if (cpu.memory[0] == 0x05)
|
||||||
|
{ // MOVZ placeholder
|
||||||
code[offset++] = 0x48; // mov rax, imm64
|
code[offset++] = 0x48; // mov rax, imm64
|
||||||
code[offset++] = 0xB8;
|
code[offset++] = 0xB8;
|
||||||
uint64_t imm = 5;
|
uint64_t imm = 5;
|
||||||
|
|
@ -20,7 +22,8 @@ void JIT::translate_and_run(CPU& cpu) {
|
||||||
offset += 8;
|
offset += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpu.memory[4] == 0x03) { // ADD placeholder
|
if (cpu.memory[4] == 0x03)
|
||||||
|
{ // ADD placeholder
|
||||||
code[offset++] = 0x48; // add rax, imm32
|
code[offset++] = 0x48; // add rax, imm32
|
||||||
code[offset++] = 0x05;
|
code[offset++] = 0x05;
|
||||||
uint32_t addval = 3;
|
uint32_t addval = 3;
|
||||||
|
|
@ -32,13 +35,12 @@ void JIT::translate_and_run(CPU& cpu) {
|
||||||
|
|
||||||
JitFunc fn = reinterpret_cast<JitFunc>(code);
|
JitFunc fn = reinterpret_cast<JitFunc>(code);
|
||||||
uint64_t result;
|
uint64_t result;
|
||||||
asm volatile (
|
asm volatile(
|
||||||
"call *%1\n"
|
"call *%1\n"
|
||||||
"mov %%rax, %0\n"
|
"mov %%rax, %0\n"
|
||||||
: "=r"(result)
|
: "=r"(result)
|
||||||
: "r"(fn)
|
: "r"(fn)
|
||||||
: "%rax"
|
: "%rax");
|
||||||
);
|
|
||||||
|
|
||||||
cpu.regs[0] = result;
|
cpu.regs[0] = result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef JIT_H
|
#ifndef JIT_H
|
||||||
#define JIT_H
|
#define JIT_H
|
||||||
#include "core/ARM/cpu.h"
|
#include "cpu.h"
|
||||||
|
|
||||||
class JIT {
|
class JIT
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
void translate_and_run(CPU& cpu);
|
void translate_and_run(CPU &cpu);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
#include "core/ARM/cpu.h"
|
#include "cpu.h"
|
||||||
#include "core/JIT/jit.h"
|
#include "jit.h"
|
||||||
|
|
||||||
int main() {
|
#include <cstdio>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
CPU cpu;
|
CPU cpu;
|
||||||
cpu.pc = 0;
|
cpu.pc = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue