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
|
#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 C (1 << 0)
#define Z (1 << 1)
#define I (1 << 2)
#define V (1 << 6)
#define N (1 << 7)
extern uint8_t get_addrsize(uint8_t prefix, uint8_t addrmode);
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 pc;
uint16_t sp;
uint16_t stk_st;
uint64_t clk;
uint8_t crt;
};
extern int asmmon();
enum sw_type {RS, AM, BYTE};
|