Now encoding sethi instructions as well
This commit is contained in:
parent
9b692011ca
commit
33039927e3
@ -65,6 +65,8 @@ ArchPlugin arch_plugin =
|
|||||||
/* sparc_write */
|
/* sparc_write */
|
||||||
static int _write_loadstore(ArchPlugin * plugin, ArchInstruction * instruction,
|
static int _write_loadstore(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
ArchInstructionCall * call, uint32_t * opcode);
|
ArchInstructionCall * call, uint32_t * opcode);
|
||||||
|
static int _write_sethi(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call, uint32_t * opcode);
|
||||||
|
|
||||||
static int _sparc_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
static int _sparc_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
ArchInstructionCall * call)
|
ArchInstructionCall * call)
|
||||||
@ -74,6 +76,9 @@ static int _sparc_write(ArchPlugin * plugin, ArchInstruction * instruction,
|
|||||||
if((opcode & 0xc0000000) == 0xc0000000 && _write_loadstore(plugin,
|
if((opcode & 0xc0000000) == 0xc0000000 && _write_loadstore(plugin,
|
||||||
instruction, call, &opcode) != 0)
|
instruction, call, &opcode) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
else if((opcode & 0x01000000) == 0x01000000 && _write_sethi(plugin,
|
||||||
|
instruction, call, &opcode) != 0)
|
||||||
|
return -1;
|
||||||
/* FIXME implement the rest */
|
/* FIXME implement the rest */
|
||||||
opcode = _htob32(opcode);
|
opcode = _htob32(opcode);
|
||||||
if(fwrite(&opcode, sizeof(opcode), 1, plugin->helper->fp) != 1)
|
if(fwrite(&opcode, sizeof(opcode), 1, plugin->helper->fp) != 1)
|
||||||
@ -166,3 +171,28 @@ static int _write_loadstore(ArchPlugin * plugin, ArchInstruction * instruction,
|
|||||||
*opcode |= (rd | rs1 | rs2);
|
*opcode |= (rd | rs1 | rs2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _write_sethi(ArchPlugin * plugin, ArchInstruction * instruction,
|
||||||
|
ArchInstructionCall * call, uint32_t * opcode)
|
||||||
|
{
|
||||||
|
ArchPluginHelper * helper = plugin->helper;
|
||||||
|
uint32_t rd;
|
||||||
|
uint32_t value;
|
||||||
|
char const * name;
|
||||||
|
ArchRegister * ar;
|
||||||
|
|
||||||
|
/* value */
|
||||||
|
if(AO_GET_TYPE(instruction->op1) != AOT_IMMEDIATE)
|
||||||
|
return -1;
|
||||||
|
value = (call->operands[0].value.immediate.value >> 10);
|
||||||
|
/* rd */
|
||||||
|
if(AO_GET_TYPE(instruction->op2) != AOT_REGISTER)
|
||||||
|
return -1;
|
||||||
|
name = call->operands[1].value._register.name;
|
||||||
|
if((ar = helper->get_register_by_name_size(helper->arch,
|
||||||
|
name, 32)) == NULL)
|
||||||
|
return -1;
|
||||||
|
rd = (ar->id << 25);
|
||||||
|
*opcode |= (rd | value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
sdiv %r29, -$23, %r19
|
sdiv %r29, -$23, %r19
|
||||||
sdivcc %r16, %r26, %r27
|
sdivcc %r16, %r26, %r27
|
||||||
sdivcc %r29, -$23, %r19
|
sdivcc %r29, -$23, %r19
|
||||||
sethi $0x87654321, %r2
|
sethi $0x87654321, %r2 /* 0x0521d950 */
|
||||||
smul %r16, %r26, %r27
|
smul %r16, %r26, %r27
|
||||||
smul %r29, -$23, %r19
|
smul %r29, -$23, %r19
|
||||||
smulcc %r16, %r26, %r27
|
smulcc %r16, %r26, %r27
|
||||||
|
Loading…
Reference in New Issue
Block a user