Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarofe committed Jun 15, 2015
1 parent c871d8e commit 31cfebd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions libr/core/cmd_anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,10 @@ void cmd_anal_reg(RCore *core, const char *str) {
r_cons_printf ("%s\n", name);
break;
case 'n': // "drn"
if (*(str+1) == '\0'){
eprintf ("Oops. try drn [pc|sp|bp|a0|a1|a2|a3|zf|sf|nf|of]\n");
break;
}
name = r_reg_get_name (core->dbg->reg, r_reg_get_name_idx (str+2));
if (name && *name)
r_cons_printf ("%s\n", name);
Expand Down
42 changes: 21 additions & 21 deletions libr/reg/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ static void r_reg_item_free(RRegItem *item) {
}

R_API int r_reg_get_name_idx(const char *type) {
if (type)
switch (*type | (type[1]<<8)) {
/* flags */
case 'z'+('f'<<8): return R_REG_NAME_ZF;
case 's'+('f'<<8): return R_REG_NAME_SF;
case 'c'+('f'<<8): return R_REG_NAME_CF;
case 'o'+('f'<<8): return R_REG_NAME_OF;
/* gpr */
case 'p'+('c'<<8): return R_REG_NAME_PC;
case 's'+('r'<<8): return R_REG_NAME_SR;
case 's'+('p'<<8): return R_REG_NAME_SP;
case 'b'+('p'<<8): return R_REG_NAME_BP;
case 's'+('n'<<8): return R_REG_NAME_SN;
/* args */
case 'a'+('0'<<8): return R_REG_NAME_A0;
case 'a'+('1'<<8): return R_REG_NAME_A1;
case 'a'+('2'<<8): return R_REG_NAME_A2;
case 'a'+('3'<<8): return R_REG_NAME_A3;
case 'a'+('4'<<8): return R_REG_NAME_A4;
case 'a'+('5'<<8): return R_REG_NAME_A5;
case 'a'+('6'<<8): return R_REG_NAME_A6;
if (type && *type != '\0')
switch (*type | (type[1]<<8)) {
/* flags */
case 'z'+('f'<<8): return R_REG_NAME_ZF;
case 's'+('f'<<8): return R_REG_NAME_SF;
case 'c'+('f'<<8): return R_REG_NAME_CF;
case 'o'+('f'<<8): return R_REG_NAME_OF;
/* gpr */
case 'p'+('c'<<8): return R_REG_NAME_PC;
case 's'+('r'<<8): return R_REG_NAME_SR;
case 's'+('p'<<8): return R_REG_NAME_SP;
case 'b'+('p'<<8): return R_REG_NAME_BP;
case 's'+('n'<<8): return R_REG_NAME_SN;
/* args */
case 'a'+('0'<<8): return R_REG_NAME_A0;
case 'a'+('1'<<8): return R_REG_NAME_A1;
case 'a'+('2'<<8): return R_REG_NAME_A2;
case 'a'+('3'<<8): return R_REG_NAME_A3;
case 'a'+('4'<<8): return R_REG_NAME_A4;
case 'a'+('5'<<8): return R_REG_NAME_A5;
case 'a'+('6'<<8): return R_REG_NAME_A6;
}
return -1;
}
Expand Down

0 comments on commit 31cfebd

Please sign in to comment.