Implement SWI

This commit is contained in:
Jeffrey Pfau 2013-04-14 11:57:39 -07:00
parent 475af6fde2
commit 7c5a6b121c
4 changed files with 21 additions and 1 deletions

View File

@ -85,6 +85,8 @@ struct ARMMemory {
struct ARMBoard {
struct ARMCore* cpu;
void (*reset)(struct ARMBoard* board);
void (*swi16)(struct ARMBoard* board, int immediate);
void (*swi32)(struct ARMBoard* board, int immediate);
void (*hitStub)(struct ARMBoard* board, uint32_t opcode);
};

View File

@ -21,6 +21,9 @@ static void GBAStore32(struct ARMMemory* memory, uint32_t address, int32_t value
static void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value);
static void GBAStore8(struct ARMMemory* memory, uint32_t address, int8_t value);
static void GBASwi16(struct ARMBoard* board, int immediate);
static void GBASwi32(struct ARMBoard* board, int immediate);
static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t region);
static void GBAHitStub(struct ARMBoard* board, uint32_t opcode);
@ -81,6 +84,8 @@ void GBAMemoryDeinit(struct GBAMemory* memory) {
void GBABoardInit(struct GBABoard* board) {
board->d.reset = GBABoardReset;
board->d.swi16 = GBASwi16;
board->d.swi32 = GBASwi32;
board->d.hitStub = GBAHitStub;
}
@ -396,6 +401,17 @@ void GBAStore8(struct ARMMemory* memory, uint32_t address, int8_t value) {
}
}
static void GBASwi16(struct ARMBoard* board, int immediate) {
switch (immediate) {
default:
GBALog(GBA_LOG_STUB, "Stub software interrupt: %02x", immediate);
}
}
static void GBASwi32(struct ARMBoard* board, int immediate) {
GBASwi32(board, immediate >> 8);
}
void GBALog(int level, const char* format, ...) {
va_list args;
va_start(args, format);

View File

@ -251,4 +251,6 @@ void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);
void GBALoadROM(struct GBA* gba, int fd);
void GBALog(int level, const char* format, ...);
#endif

View File

@ -410,7 +410,7 @@ DEFINE_INSTRUCTION_THUMB(BX, \
ARM_WRITE_PC; \
})
DEFINE_INSTRUCTION_THUMB(SWI, ARM_STUB)
DEFINE_INSTRUCTION_THUMB(SWI, cpu->board->swi16(cpu->board, opcode & 0xFF))
#define DECLARE_INSTRUCTION_THUMB(EMITTER, NAME) \
EMITTER ## NAME