vmcu_access_t - Milo-D/libvmcu-Virtual-MCU-Library GitHub Wiki
Definition
Defined in libvmcu_analyzer.h |
---|
typedef struct vmcu_access { ... } vmcu_access_t; |
Description
vmcu_access_t
holds several bitfields which should be interpreted as booleans. This structure is being used by
vmcu_instr_t
to store information on read/write memory access of each individual instruction.
typedef struct vmcu_access { ///< abstract memory access structure
/* larger segments */
unsigned int registers : 1; ///< accessing registers ?
unsigned int flash : 1; ///< accessing flash ?
unsigned int stack : 1; ///< accessing stack ?
unsigned int io : 1; ///< acccessing io ?
unsigned int ds : 1; ///< accessing data segment ?
/* special pointers */
unsigned int sp : 1; ///< accessing stack pointer ?
unsigned int pc : 1; ///< accessing program counter ?
/* status flags */
unsigned int c_flag : 1; ///< accessing carry flag ?
unsigned int z_flag : 1; ///< accessing zero flag ?
unsigned int n_flag : 1; ///< accessing negative flag ?
unsigned int v_flag : 1; ///< accessing overflow flag ?
unsigned int s_flag : 1; ///< accessing sign flag ?
unsigned int h_flag : 1; ///< accessing half-carry flag ?
unsigned int t_flag : 1; ///< accessing t-flag ?
unsigned int i_flag : 1; ///< accessing interrupt flag ?
} vmcu_access_t;
[!]
Technically if an instruction has access to the I/O segment, it automatically has access to the data
segment, since i/o ⊂ data
. But libvmcu will only set the smallest segments of the dataspace to true.
Example
#include "libvmcu_analyzer.h" // vmcu_access_t
int main(const int argc, const char **argv) {
vmcu_instr_t instr;
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_disassemble_bytes(0xddf1, &instr, m328p);
if(instr.writes.pc == true)
printf("instr has implicit/explicit write access to the program counter.\n");
vmcu_model_dtor(m328p);
return 0;
}
Possible Output
instr has implicit/explicit write access to the program counter.