aboutsummaryrefslogtreecommitdiff
path: root/ARM.cpp
blob: 2e51d86c3dc167ca96938a5ecf77cc4964214b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include "NDS.h"
#include "ARM.h"
#include "ARMInterpreter.h"


ARM::ARM(u32 num)
{
    // well uh
    Num = num;
}

ARM::~ARM()
{
    // dorp
}

void ARM::Reset()
{
    for (int i = 0; i < 16; i++)
        R[i] = 0;

    ExceptionBase = Num ? 0x00000000 : 0xFFFF0000;

    // zorp
    JumpTo(ExceptionBase);
}

void ARM::JumpTo(u32 addr)
{
    // pipeline shit

    // TODO: THUMB!!
    if (addr&1) printf("!!! THUMB JUMP\n");

    NextInstr = Read32(addr);
    R[15] = addr+4;
}

s32 ARM::Execute(s32 cycles)
{
    while (cycles > 0)
    {
        // TODO THUM SHIT ASGAFDGSUHAJISGFYAUISAGY

        // prefetch
        CurInstr = NextInstr;
        NextInstr = Read32(R[15]);
        R[15] += 4;

        // actually execute
        if ((CurInstr & 0xF0000000) != 0xE0000000) printf("well shit\n");
        u32 icode = ((CurInstr >> 4) & 0xF) | ((CurInstr >> 16) & 0xFF0);
        cycles -= ARMInterpreter::ARMInstrTable[icode](this);
    }

    return cycles;
}