VMCU_IKEY - Milo-D/libvmcu-Virtual-MCU-Library GitHub Wiki

Definition

Defined in libvmcu_analyzer.h
typedef enum { ..., VMCU_IKEY_LDI, ... } VMCU_IKEY;

Description

VMCU_IKEY (instruction key) is an enumeration of AVR instructions. For example VMCU_IKEY_MOVW = movw.

Example

#include "libvmcu_analyzer.h" // VMCU_IKEY

int main(const int argc, const char **argv) {
   
    vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);

    vmcu_instr_t instr;
    vmcu_disassemble_bytes(0xf49a, &instr, m328p);

    // is current instruction a jmp or rjmp ?
    if(instr.key == VMCU_IKEY_JMP || instr.key == VMCU_IKEY_RJMP) {

        printf("0x%04" PRIx32 "\t", instr.addr);
        printf("%s %s\n", instr.mnem.base, instr.mnem.src);
    }

    vmcu_model_dtor(m328p);
    return 0;
}

Possible Output

0x0000 jmp 0x0028
0x004a rjmp -1
0x02f3 jmp 64

Notes

1 The integer value of a single VMCU_IKEY does not have a special meaning.
2 VMCU_IKEY_DATA (= -1) is not a real instruction but stands for .dw directive
3 Illegal opcodes are translated into .dw directives.