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
|
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "tables.h"
#define keypoll 0
#define OPNUM 74
#define EXT_OPNUM 49
#define ORTHO_OPNUM 16
#define C (1 << 0)
#define Z (1 << 1)
#define I (1 << 2)
#define V (1 << 6)
#define N (1 << 7)
extern char *showbits(uint64_t value, uint8_t bitnum, uint8_t dbg);
#define setreg(reg, reg_expr, reg_idx, val, val_expr, val_idx, size) {\
switch (size) {\
case 7: reg[(reg_idx) reg_expr 7] = val[(val_idx) val_expr 7];\
case 6: reg[(reg_idx) reg_expr 6] = val[(val_idx) val_expr 6];\
case 5: reg[(reg_idx) reg_expr 5] = val[(val_idx) val_expr 5];\
case 4: reg[(reg_idx) reg_expr 4] = val[(val_idx) val_expr 4];\
case 3: reg[(reg_idx) reg_expr 3] = val[(val_idx) val_expr 3];\
case 2: reg[(reg_idx) reg_expr 2] = val[(val_idx) val_expr 2];\
case 1: reg[(reg_idx) reg_expr 1] = val[(val_idx) val_expr 1];\
case 0: reg[(reg_idx) reg_expr 0] = val[(val_idx) val_expr 0];\
}\
}
#define setreg_sw(reg, reg_idx, val, val_idx, prefix, addrmode, type) {\
switch (type) {\
case RS: setreg(reg, +, reg_idx, val, +, val_idx, (1 << ((prefix >> 4) & 3))-1); break;\
case AM: setreg(reg, +, reg_idx, val, +, val_idx, get_addrsize(prefix, addrmode)); break;\
}\
}
extern uint8_t *addr;
union reg {
uint8_t u8[8];
uint16_t u16[4];
uint32_t u32[2];
uint64_t u64;
};
struct sux {
union reg ps;
uint64_t a, b, y, x;
uint64_t e;
uint64_t c, d, s, f; ;
uint64_t pc;
uint64_t sp;
uint64_t bp;
uint64_t r11, r12, r13, r14, r15; ;
uint64_t clk;
};
typedef struct op operand;
struct op {
uint8_t type;
uint8_t id;
uint8_t rind[2];
uint8_t scale;
int is_ind : 1;
uint8_t cc;
uint64_t value;
};
extern int asmmon();
enum sw_type {RS, AM, BYTE};
|