8 typedef uint16_t inst_t
; // instruction
9 typedef uint8_t oper_t
; // operand
17 /* operand definitions */
19 #define OP_INV 0x0 /* invalid or not used */
20 #define OP_REG 0x1 /* register */
21 #define OP_IMM 0x2 /* immediate */
23 /* just for your convenience */
24 #define OP_RI (OP_REG | OP_IMM)
26 /* maximum number of operands */
35 struct operand operands
[OP_MAX
];
38 /* instruction types */
45 /* instruction offsets */
49 #define OFF_IMM_DEST OFF_SRC2
52 #define OFF_MEM_REG_SRC1 10
53 #define OFF_MEM_REG_DEST 6
54 #define OFF_MEM_IMM_DEST 8
60 #define BIT_IMM 0x8000
64 /* set_reg(): set register 'reg' at offset 'off' in 'instruction' */
65 static inline void set_reg(inst_t
*instruction
, oper_t reg
, int off
)
67 *instruction
|= ((inst_t
) (reg
<< off
));
70 /* set_imm(): set immediate 'imm' in 'instruction' */
71 static inline void set_imm(inst_t
*instruction
, oper_t imm
)
73 *instruction
|= BIT_IMM
;
74 *instruction
|= ((inst_t
) (MASK_IMM
& imm
));
77 /* exported functions */
78 struct opcode
*opcode_lookup(const char *mnemonic
);
80 #endif /* _DAS_OPCODE_H */