Skip to content

Commit

Permalink
Add M68K_reg_access
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Aug 6, 2024
1 parent 74ddce8 commit 5926fc8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
21 changes: 21 additions & 0 deletions arch/M68K/M68KInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,24 @@ const char *M68K_group_name(csh handle, unsigned int id)
#endif
}

#ifndef CAPSTONE_DIET
void M68K_reg_access(const cs_insn *insn,
cs_regs regs_read, uint8_t *regs_read_count,
cs_regs regs_write, uint8_t *regs_write_count)
{
uint8_t read_count, write_count;

read_count = insn->detail->regs_read_count;
write_count = insn->detail->regs_write_count;

// implicit registers
memcpy(regs_read, insn->detail->regs_read,
read_count * sizeof(insn->detail->regs_read[0]));
memcpy(regs_write, insn->detail->regs_write,
write_count * sizeof(insn->detail->regs_write[0]));

*regs_read_count = read_count;
*regs_write_count = write_count;
}
#endif

5 changes: 5 additions & 0 deletions arch/M68K/M68KInstPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ void M68K_get_insn_id(cs_struct* h, cs_insn* insn, unsigned int id);
const char *M68K_insn_name(csh handle, unsigned int id);
const char* M68K_group_name(csh handle, unsigned int id);
void M68K_post_printer(csh handle, cs_insn* flat_insn, char* insn_asm, MCInst* mci);
#ifndef CAPSTONE_DIET
void M68K_reg_access(const cs_insn *insn,
cs_regs regs_read, uint8_t *regs_read_count,
cs_regs regs_write, uint8_t *regs_write_count);
#endif

#endif
5 changes: 4 additions & 1 deletion arch/M68K/M68KModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cs_err M68K_global_init(cs_struct *ud)
{
m68k_info *info;

info = cs_mem_malloc(sizeof(m68k_info));
info = cs_mem_calloc(sizeof(m68k_info), 1);
if (!info) {
return CS_ERR_MEM;
}
Expand All @@ -29,6 +29,9 @@ cs_err M68K_global_init(cs_struct *ud)
ud->insn_id = M68K_get_insn_id;
ud->insn_name = M68K_insn_name;
ud->group_name = M68K_group_name;
#ifndef CAPSTONE_DIET
ud->reg_access = M68K_reg_access;
#endif

return CS_ERR_OK;
}
Expand Down

0 comments on commit 5926fc8

Please sign in to comment.