From 7edc2f2b6a9fd7b76fdf0897071eaa4a6893c303 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 4 Jun 2011 13:16:36 +0000 Subject: [PATCH] Added the "nop" instruction for sparc{,64} --- src/arch/sparc.h | 5 ++++- src/arch/sparc.ins | 3 ++- test/sparc.S | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/arch/sparc.h b/src/arch/sparc.h index 28ab1a8..ed3131b 100644 --- a/src/arch/sparc.h +++ b/src/arch/sparc.h @@ -42,7 +42,7 @@ static int _sparc_decode(ArchPlugin * plugin, ArchInstructionCall * call) u32 = _htob32(u32); if((u32 & 0xc0000000) == 0xc0000000) /* load store */ opcode = u32 & (0xc0000000 | (0xf << 19) | (0x1 << 13)); - else if((u32 & 0xc1c00000) == 0x01000000) /* sethi */ + else if((u32 & 0xc1c00000) == 0x01000000) /* nop, sethi */ opcode = u32 & (0x7 << 22); else if((u32 & 0xc0000000) == 0x80000000) /* integer arithmetic */ opcode = u32 & (0x80000000 | (0x1f << 19) | (0x1 << 13)); @@ -272,6 +272,9 @@ static int _write_sethi(ArchPlugin * plugin, ArchInstruction * instruction, char const * name; ArchRegister * ar; + /* nop */ + if(AO_GET_TYPE(instruction->op1) == AOT_NONE) + return 0; /* value */ if(AO_GET_TYPE(instruction->op1) != AOT_IMMEDIATE) return -1; diff --git a/src/arch/sparc.ins b/src/arch/sparc.ins index 74ae5b7..757fabf 100644 --- a/src/arch/sparc.ins +++ b/src/arch/sparc.ins @@ -152,6 +152,7 @@ { "ldub", OPLS1(ldub), OPLS1F, OPLS_RS12,OP_RD, AOT_NONE }, { "lduh", OPLS1(lduh), OPLS1F, OPLS_RS1, OP_RD, AOT_NONE }, { "lduh", OPLS1(lduh), OPLS1F, OPLS_RS12,OP_RD, AOT_NONE }, +{ "nop", OPSH(sethi), OPSHF, AOT_NONE, AOT_NONE, AOT_NONE }, { "or", OPIA1(or), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, { "or", OPIA2(or), OPIA2F, OPIA_RS1, OPIA_U12, OP_RD }, { "orcc", OPIA1(orcc), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, @@ -160,11 +161,11 @@ { "orn", OPIA2(orn), OPIA2F, OPIA_RS1, OPIA_U12, OP_RD }, { "orncc", OPIA1(orncc), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, { "orncc", OPIA2(orncc), OPIA2F, OPIA_RS1, OPIA_U12, OP_RD }, -{ "sethi", OPSH(sethi), OPSHF, OPSH_U21, OP_RD, AOT_NONE }, { "sdiv", OPIA1(sdiv), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, { "sdiv", OPIA2(sdiv), OPIA2F, OPIA_RS1, OPIA_U12, OP_RD }, { "sdivcc", OPIA1(sdivcc), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, { "sdivcc", OPIA2(sdivcc), OPIA2F, OPIA_RS1, OPIA_U12, OP_RD }, +{ "sethi", OPSH(sethi), OPSHF, OPSH_U21, OP_RD, AOT_NONE }, { "smul", OPIA1(smul), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, { "smul", OPIA2(smul), OPIA2F, OPIA_RS1, OPIA_S12, OP_RD }, { "smulcc", OPIA1(smulcc), OPIA1F, OPIA_RS1, OPIA_RS2, OP_RD }, diff --git a/test/sparc.S b/test/sparc.S index e8cfec6..718b2c6 100644 --- a/test/sparc.S +++ b/test/sparc.S @@ -36,6 +36,7 @@ ldub [%r23], %r19 lduh [%r4 + %r7], %r11 lduh [%r23], %r19 + nop or %r16, %r26, %r27 or %r29, -$23, %r19 orcc %r16, %r26, %r27