File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /build
2+ * ~
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 2.6 )
2+ project (GBAc)
3+ file (GLOB SOURCES *.c )
4+ add_executable (gbac ${SOURCES} )
Original file line number Diff line number Diff line change 1+ #include "arm.h"
2+
3+ void ARMInit (struct ARMCore * cpu ) {
4+ int i ;
5+ for (i = 0 ; i < 16 ; ++ i ) {
6+ cpu -> gprs [i ] = 0 ;
7+ }
8+
9+ cpu -> cpsr .packed = 0 ;
10+ cpu -> spsr .packed = 0 ;
11+
12+ cpu -> cyclesToEvent = 0 ;
13+
14+ cpu -> shifterOperand = 0 ;
15+ cpu -> shifterCarryOut = 0 ;
16+
17+ cpu -> memory = 0 ;
18+ cpu -> board = 0 ;
19+ }
20+
21+ void ARMCycle (struct ARMCore * cpu ) {
22+ // TODO
23+ }
Original file line number Diff line number Diff line change 1+ #ifndef ARM_H
2+ #define ARM_H
3+
4+ #include <stdint.h>
5+
6+ enum {
7+ ARM_SP = 13 ,
8+ ARM_LR = 14 ,
9+ ARM_PC = 15
10+ };
11+
12+ enum ExecutionMode {
13+ MODE_ARM = 0 ,
14+ MODE_THUMB = 1
15+ };
16+
17+ enum PrivilegeMode {
18+ MODE_USER = 0x10 ,
19+ MODE_FIQ = 0x11 ,
20+ MODE_IRQ = 0x12 ,
21+ MODE_SUPERVISOR = 0x13 ,
22+ MODE_ABORT = 0x17 ,
23+ MODE_UNDEFINED = 0x1B ,
24+ MODE_SYSTEM = 0x1F
25+ };
26+
27+ enum ExecutionVector {
28+ BASE_RESET = 0x00000000 ,
29+ BASE_UNDEF = 0x00000004 ,
30+ BASE_SWI = 0x00000008 ,
31+ BASE_PABT = 0x0000000C ,
32+ BASE_DABT = 0x00000010 ,
33+ BASE_IRQ = 0x00000018 ,
34+ BASE_FIQ = 0x0000001C
35+ };
36+
37+ union PSR {
38+ struct {
39+ int exec : 4 ;
40+ int t : 1 ;
41+ int f : 1 ;
42+ int i : 1 ;
43+ int a : 1 ;
44+ int : 20 ;
45+ int v : 1 ;
46+ int c : 1 ;
47+ int z : 1 ;
48+ int n : 1 ;
49+ };
50+
51+ int32_t packed ;
52+ };
53+
54+ struct ARMMemory ;
55+ struct ARMBoard ;
56+
57+ struct ARMCore {
58+ int32_t gprs [16 ];
59+ union PSR cpsr ;
60+ union PSR spsr ;
61+
62+ int32_t cyclesToEvent ;
63+
64+ int32_t shifterOperand ;
65+ int32_t shifterCarryOut ;
66+
67+ struct ARMMemory * memory ;
68+ struct ARMBoard * board ;
69+ };
70+
71+ void ARMInit (struct ARMCore * cpu );
72+ void ARMCycle (struct ARMCore * cpu );
73+
74+ #endif
Original file line number Diff line number Diff line change 1+ #include "arm.h"
2+
3+ int main (int argc , char * * argv ) {
4+ struct ARMCore cpu ;
5+ ARMInit (& cpu );
6+
7+ return 0 ;
8+ }
You can’t perform that action at this time.
0 commit comments