mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 19:47:31 +00:00
* Fix negative offsets in memory addressing opcodes
for udis86 disassembly for intel and at&t syntaxes * Show olly disasm widespaced
This commit is contained in:
parent
b8c3a23892
commit
d3e6e6f2ec
@ -16,7 +16,6 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
#define STRICT
|
||||
|
||||
#include <stdio.h>
|
||||
@ -32,7 +31,7 @@ static int lowercase = 1; // Force lowercase display XXX remove it
|
||||
#if 1
|
||||
static int ideal; // Force IDEAL decoding mode
|
||||
static int tabarguments; // Tab between mnemonic and arguments
|
||||
static int extraspace; // Extra space between arguments
|
||||
static int extraspace = 1; // Extra space between arguments
|
||||
static int putdefseg; // Display default segments in listing
|
||||
static int showmemsize; // Always show memory size
|
||||
static int shownear; // Show NEAR modifiers
|
||||
|
@ -33,6 +33,7 @@ opr_cast(struct ud* u, struct ud_operand* op)
|
||||
static void
|
||||
gen_operand(struct ud* u, struct ud_operand* op)
|
||||
{
|
||||
int op_f = op->base;
|
||||
switch(op->type) {
|
||||
case UD_OP_REG:
|
||||
mkasm(u, "%%%s", ud_reg_tab[op->base - UD_R_AL]);
|
||||
@ -47,12 +48,27 @@ gen_operand(struct ud* u, struct ud_operand* op)
|
||||
mkasm(u, "-0x%x", (-op->lval.sbyte) & 0xff);
|
||||
else mkasm(u, "0x%x", op->lval.sbyte);
|
||||
}
|
||||
else if (op->offset == 16)
|
||||
mkasm(u, "0x%x", op->lval.uword);
|
||||
else if (op->offset == 32)
|
||||
mkasm(u, "0x%lx", op->lval.udword);
|
||||
else if (op->offset == 64)
|
||||
else if (op->offset == 16) {
|
||||
if (op->lval.sbyte < 0)
|
||||
mkasm(u, "-0x%x", -op->lval.uword);
|
||||
else if (op->lval.sbyte > 0)
|
||||
mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.uword);
|
||||
} else if (op->offset == 32) {
|
||||
if (u->adr_mode == 64) {
|
||||
if (op->lval.sdword < 0)
|
||||
mkasm(u, "-0x%x", -op->lval.sdword);
|
||||
else if (op->lval.sdword > 0)
|
||||
mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.sdword);
|
||||
} else {
|
||||
if (op->lval.sdword < 0)
|
||||
mkasm(u, "-0x%lx", -op->lval.udword);
|
||||
else if (op->lval.sdword > 0)
|
||||
mkasm(u, "%s0x%lx", (op_f)?"+":"",op->lval.udword);
|
||||
}
|
||||
} else if (op->offset == 64) {
|
||||
// TODO: Implement 64 bit negative offsets
|
||||
mkasm(u, "0x" FMT64 "x", op->lval.uqword);
|
||||
}
|
||||
|
||||
if (op->base)
|
||||
mkasm(u, "(%%%s", ud_reg_tab[op->base - UD_R_AL]);
|
||||
|
@ -74,20 +74,29 @@ static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
|
||||
if (op->offset == 8) {
|
||||
if (op->lval.sbyte < 0)
|
||||
mkasm(u, "-0x%x", -op->lval.sbyte);
|
||||
else mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.sbyte);
|
||||
}
|
||||
else if (op->offset == 16)
|
||||
mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.uword);
|
||||
else if (op->offset == 32) {
|
||||
else if (op->lval.sbyte > 0)
|
||||
mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.sbyte);
|
||||
} else if (op->offset == 16) {
|
||||
if (op->lval.sbyte < 0)
|
||||
mkasm(u, "-0x%x", -op->lval.uword);
|
||||
else if (op->lval.sbyte > 0)
|
||||
mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.uword);
|
||||
} else if (op->offset == 32) {
|
||||
if (u->adr_mode == 64) {
|
||||
if (op->lval.sdword < 0)
|
||||
mkasm(u, "-0x%x", -op->lval.sdword);
|
||||
else mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.sdword);
|
||||
}
|
||||
else mkasm(u, "%s0x%lx", (op_f) ? "+" : "", op->lval.udword);
|
||||
}
|
||||
else if (op->offset == 64)
|
||||
else if (op->lval.sdword > 0)
|
||||
mkasm(u, "%s0x%x", (op_f) ? "+" : "", op->lval.sdword);
|
||||
} else {
|
||||
if (op->lval.sdword < 0)
|
||||
mkasm(u, "-0x%lx", -op->lval.udword);
|
||||
else if (op->lval.sdword > 0)
|
||||
mkasm(u, "%s0x%lx", (op_f)?"+":"",op->lval.udword);
|
||||
}
|
||||
} else if (op->offset == 64) {
|
||||
// TODO: Implement 64 bit negative offsets
|
||||
mkasm(u, "%s0x" FMT64 "x", (op_f) ? "+" : "", op->lval.uqword);
|
||||
}
|
||||
|
||||
mkasm(u, "]");
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user