-
Notifications
You must be signed in to change notification settings - Fork 0
/
processor.h
executable file
·55 lines (47 loc) · 985 Bytes
/
processor.h
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
#ifndef __PROCESSOR_H
#define __PROCESSOR_H
#include <stdint.h>
#include "memory.h"
typedef uint32_t reg_t;
typedef struct
{
unsigned int funct : 6;
unsigned int shamt : 5;
unsigned int rd : 5;
unsigned int rt : 5;
unsigned int rs : 5;
unsigned int opcode : 6;
} rtype_inst_t;
typedef struct
{
unsigned int imm : 16;
unsigned int rt : 5;
unsigned int rs : 5;
unsigned int opcode : 6;
} itype_inst_t;
typedef struct
{
unsigned int addr : 26;
unsigned int opcode : 6;
} jtype_inst_t;
typedef union
{
rtype_inst_t rtype;
itype_inst_t itype;
jtype_inst_t jtype;
int16_t chunks16[2];
uint32_t bits;
} inst_t;
typedef struct
{
reg_t R[32];
reg_t RHI;
reg_t RLO;
reg_t pc;
} processor_t;
void execute_one_inst(processor_t* p, int prompt, int print_regs);
void perform_mult(reg_t, reg_t, reg_t*, reg_t*);
void init_processor(processor_t* p);
void print_registers(processor_t* p);
void handle_syscall(processor_t* p);
#endif // __PROCESSOR_H