summaryrefslogtreecommitdiff
path: root/register.c
blob: f197513d2f32dadba94589cf5383eab8d3c76b7c (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "register.h"
#include <stddef.h>

struct reg RAX = {
    .qword = "rax",
    .dword = "eax",
    .word = "ax",
    .byte = "al",
    .is_occupied = false,
};
struct reg RBX = {
    .qword = "rbx",
    .dword = "ebx",
    .word = "bx",
    .byte = "bl",
    .is_occupied = false,
};
struct reg RCX = {
    .qword = "rcx",
    .dword = "ecx",
    .word = "cx",
    .byte = "cl",
    .is_occupied = false,
};
struct reg RDX = {
    .qword = "rdx",
    .dword = "edx",
    .word = "dx",
    .byte = "dl",
    .is_occupied = false,
};

struct reg RDI = {
    .qword = "rdi",
    .dword = "edi",
    .word = "di",
    .byte = "dil",
    .is_occupied = false,
};
struct reg RSI = {
    .qword = "rsi",
    .dword = "esi",
    .word = "si",
    .byte = "sil",
    .is_occupied = false,
};
struct reg RSP = {
    .qword = "rsp",
    .dword = "esp",
    .word = "sp",
    .byte = "spl",
    .is_occupied = true,
};
struct reg RBP = {
    .qword = "rbp",
    .dword = "ebp",
    .word = "bp",
    .byte = "bpl",
    .is_occupied = true,
};

struct reg R8 = {
    .qword = "r8",
    .dword = "r8d",
    .word = "r8w",
    .byte = "r8b",
    .is_occupied = false,
};
struct reg R9 = {
    .qword = "r9",
    .dword = "r9d",
    .word = "r9w",
    .byte = "r9b",
    .is_occupied = false,
};
struct reg R10 = {
    .qword = "r10",
    .dword = "r10d",
    .word = "r10w",
    .byte = "r10b",
    .is_occupied = false,
};
struct reg R11 = {
    .qword = "r11",
    .dword = "r11d",
    .word = "r11w",
    .byte = "r11b",
    .is_occupied = false,
};
struct reg R12 = {
    .qword = "r12",
    .dword = "r12d",
    .word = "r12w",
    .byte = "r12b",
    .is_occupied = false,
};
struct reg R13 = {
    .qword = "r13",
    .dword = "r13d",
    .word = "r13w",
    .byte = "r13b",
    .is_occupied = false,
};
struct reg R14 = {
    .qword = "r14",
    .dword = "r14d",
    .word = "r14w",
    .byte = "r14b",
    .is_occupied = false,
};
struct reg R15 = {
    .qword = "r15",
    .dword = "r15d",
    .word = "r15w",
    .byte = "r15b",
    .is_occupied = false,
};

struct reg* const CALLING_CONV[] = {&RDI, &RSI, &RDX, &R10, &R9, &R8, NULL};
struct reg* const DATA_REGS[] = {
    &RDI, &RSI, &RAX, &RBX, &RCX, &RDX,
    &R8, &R9, &R10, &R11, &R12, &R13, &R14, &R15, NULL
};