VMCU_OPTYPE - Milo-D/libvmcu-Virtual-MCU-Library GitHub Wiki
Definition
Defined in libvmcu_analyzer.h |
---|
typedef enum { ..., VMCU_OPTYPE_S12, ... } VMCU_OPTYPE; |
Description
Enumeration of assembly operand types. For example, VMCU_OPTYPE_IO5
for a 5-bit I/O address or
VMCU_OPTYPE_RP
for a registerpair.
VMCU_OPTYPE | Description |
---|---|
VMCU_OPTYPE_R |
register |
VMCU_OPTYPE_RP |
registerpair |
VMCU_OPTYPE_X |
x pointer (r27:r26) |
VMCU_OPTYPE_Y |
y pointer (r29:r28) |
VMCU_OPTYPE_Z |
z pointer (r31:r30) |
VMCU_OPTYPE_B |
bit number (0-7) |
VMCU_OPTYPE_K4 |
4-bit immediate unsigned constant |
VMCU_OPTYPE_K6 |
6-bit immediate unsigned constant |
VMCU_OPTYPE_K8 |
8-bit immediate unsigned constant |
VMCU_OPTYPE_IO5 |
5-bit io address |
VMCU_OPTYPE_IO6 |
6-bit io address |
VMCU_OPTYPE_D7 |
7-bit data address |
VMCU_OPTYPE_D16 |
16-bit data address |
VMCU_OPTYPE_P22 |
22-bit program address |
VMCU_OPTYPE_S7 |
7-bit signed displacement in units of words |
VMCU_OPTYPE_S12 |
12-bit signed displacement in units of words |
VMCU_OPTYPE
is used to indicate which union member in vmcu_operand_t
is safe to use.
union member | ...set if type = VMCU_OPTYPE_ |
---|---|
uint8_t k |
K4, K6, K8 |
uint8_t b |
B |
uint8_t io |
IO5, IO6 |
uint16_t d |
D7, D16 |
uint32_t p |
P22 |
int16_t s |
S7, S12 |
VMCU_REGISTER r |
R |
vmcu_registerpair_t rp |
RP, X, Y, Z |
Example
#include "libvmcu_analyzer.h" // VMCU_OPTYPE
static inline void print_regpair(const vmcu_registerpair_t *rp) {
printf("r%d:r%d\n", rp->high, rp->low);
}
int main(const int argc, const char **argv) {
uint32_t size = 0;
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_instr_t *prog = vmcu_disassemble_file("file.hex", &size, m328p);
for(uint32_t i = 0; i < size; i++) {
vmcu_instr_t *instr = &prog[i];
/* is source operand a registerpair ?*/
if(instr->src.type == VMCU_OPTYPE_RP)
print_regpair(&instr->src.rp);
/* is destination operand a registerpair ?*/
if(instr->dest.type == VMCU_OPTYPE_RP)
print_regpair(&instr->dest.rp);
}
free(prog);
vmcu_model_dtor(m328p);
return 0;
}
Possible Output
r31:r30
r25:r24
r29:r28
r1:r0
Notes
1 The integer value of a single VMCU_OPTYPE
does not have a special meaning
2 VMCU_OPTYPE_NONE
= -1 (no type, therefore no operand) \