-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreg.c
More file actions
48 lines (40 loc) · 936 Bytes
/
reg.c
File metadata and controls
48 lines (40 loc) · 936 Bytes
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
#include <stdint.h>
#include "env.h"
#include "reg.h"
char *reg_name(int reg)
{
static char *regname[] = {
"r0", "r1", "r2", "r3",
"r4", "r5", "r6", "r7",
"r8", "r9", "sl", "fp",
"ip", "sp", "lr", "pc"
};
return regname[reg];
}
uint32_t get_reg(struct CPUState *env, int reg)
{
return env->regs[reg];
}
void set_reg(struct CPUState *env, int reg, uint32_t val)
{
if (reg == REG_PC)
set_pc(env, val);
else
env->regs[reg] = val;
}
void set_pc(struct CPUState *env, uint32_t imm32)
{
env->regs[REG_PC] = imm32 + 4; /* on next_pc() will plus 4 */
env->pc = (imm32/4)-1;
}
uint32_t get_cpsr(struct CPUState *env)
{
/* FIXME: need more work for some bits */
uint32_t cpsr = 0;
cpsr = ((env->cpsr.N) << 31 |
(env->cpsr.Z) << 30 |
(env->cpsr.C) << 29 |
(env->cpsr.V) << 28
);
return cpsr;
}