-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASMtypedefs.c
82 lines (65 loc) · 1.63 KB
/
ASMtypedefs.c
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
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include "util/macroVectors.c"
#define asm_PC 0
#define asm_AT0 29
#define asm_AT1 30
#define asm_SP 31
#define macroTableSize 100
#define labelTableSize 100
typedef struct Label {
char* name;
int address;
struct Label* next; // for hash table of labels
} Label;
typedef enum InstructionType {OP,OP_RA,OP_RA_IMM16,OP_RA_RB,OP_RA_RB_IMM8,OP_RA_RB_RC} InstructionType;
typedef enum ops {NOP,ADD,SUB,AND,ORR,XOR,NOT,LSH,ASH,TCU,TCS,SET,MOV,LDW,STW,LDB,STB} ops;
typedef enum argTypes {NONE,RA,RB,RC,IMM8,IMM16} argTypes;
typedef struct instr_OP {
uint8_t opcode;
} instr_OP;
typedef struct instr_OP_RA {
uint8_t opcode;
uint8_t ra;
} instr_OP_RA;
typedef struct instr_OP_RA_IMM {
uint8_t opcode;
uint8_t ra;
uint16_t imm16;
} instr_OP_RA_IMM;
typedef struct instr_OP_RA_RB {
uint8_t opcode;
uint8_t ra;
uint8_t rb;
} instr_OP_RA_RB;
typedef struct instr_OP_RA_RB_IMM {
uint8_t opcode;
uint8_t ra;
uint8_t rb;
uint8_t imm8;
} instr_OP_RA_RB_IMM;
typedef struct instr_OP_RA_RB_RC {
uint8_t opcode;
uint8_t ra;
uint8_t rb;
uint8_t rc;
} instr_OP_RA_RB_RC;
typedef union Instruction {
uint32_t instruction32;
instr_OP op;
instr_OP_RA opra;
instr_OP_RA_IMM opraimm;
instr_OP_RA_RB oprarb;
instr_OP_RA_RB_IMM oprarbimm;
instr_OP_RA_RB_RC oprarbrc;
} Instruction;
typedef struct Macro {
char *name;
InstructionType instrType;
uint8_t* args;
uint8_t argSize;
Instruction instruction;
vector* submacros; // list of pointers to submacros
struct Macro* link; // for hash table of macros
} Macro;