Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Apr 4, 2013
0 parents commit 009bef8
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/build
*~
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 2.6)
project(GBAc)
file(GLOB SOURCES *.c)
add_executable(gbac ${SOURCES})
23 changes: 23 additions & 0 deletions src/arm.c
@@ -0,0 +1,23 @@
#include "arm.h"

void ARMInit(struct ARMCore* cpu) {
int i;
for (i = 0; i < 16; ++i) {
cpu->gprs[i] = 0;
}

cpu->cpsr.packed = 0;
cpu->spsr.packed = 0;

cpu->cyclesToEvent = 0;

cpu->shifterOperand = 0;
cpu->shifterCarryOut = 0;

cpu->memory = 0;
cpu->board = 0;
}

void ARMCycle(struct ARMCore* cpu) {
// TODO
}
74 changes: 74 additions & 0 deletions src/arm.h
@@ -0,0 +1,74 @@
#ifndef ARM_H
#define ARM_H

#include <stdint.h>

enum {
ARM_SP = 13,
ARM_LR = 14,
ARM_PC = 15
};

enum ExecutionMode {
MODE_ARM = 0,
MODE_THUMB = 1
};

enum PrivilegeMode {
MODE_USER = 0x10,
MODE_FIQ = 0x11,
MODE_IRQ = 0x12,
MODE_SUPERVISOR = 0x13,
MODE_ABORT = 0x17,
MODE_UNDEFINED = 0x1B,
MODE_SYSTEM = 0x1F
};

enum ExecutionVector {
BASE_RESET = 0x00000000,
BASE_UNDEF = 0x00000004,
BASE_SWI = 0x00000008,
BASE_PABT = 0x0000000C,
BASE_DABT = 0x00000010,
BASE_IRQ = 0x00000018,
BASE_FIQ = 0x0000001C
};

union PSR {
struct {
int exec : 4;
int t : 1;
int f : 1;
int i : 1;
int a : 1;
int : 20;
int v : 1;
int c : 1;
int z : 1;
int n : 1;
};

int32_t packed;
};

struct ARMMemory;
struct ARMBoard;

struct ARMCore {
int32_t gprs[16];
union PSR cpsr;
union PSR spsr;

int32_t cyclesToEvent;

int32_t shifterOperand;
int32_t shifterCarryOut;

struct ARMMemory* memory;
struct ARMBoard* board;
};

void ARMInit(struct ARMCore* cpu);
void ARMCycle(struct ARMCore* cpu);

#endif
8 changes: 8 additions & 0 deletions src/main.c
@@ -0,0 +1,8 @@
#include "arm.h"

int main(int argc, char** argv) {
struct ARMCore cpu;
ARMInit(&cpu);

return 0;
}

1 comment on commit 009bef8

@DreepyYunky
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THE START

Please sign in to comment.