From: <cap...@us...> - 2007-04-14 12:04:53
|
Revision: 54 http://svn.sourceforge.net/pearcolator/?rev=54&view=rev Author: captain5050 Date: 2007-04-14 05:04:52 -0700 (Sat, 14 Apr 2007) Log Message: ----------- Modify code format Modified Paths: -------------- src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java Modified: src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java =================================================================== --- src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java 2007-04-14 11:35:53 UTC (rev 53) +++ src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java 2007-04-14 12:04:52 UTC (rev 54) @@ -4,7 +4,7 @@ * A copy of the license is included in the distribution, and is also * available at http://www.opensource.org/licenses/cpl1.0.php * - * (C) Copyright Ian Rogers, The University of Manchester 2003-2006 + * (C) Copyright Ian Rogers, The University of Manchester 2003-2007 */ package org.binarytranslator.arch.x86.decoder; @@ -82,52 +82,52 @@ private static final X86_InstructionDecoder[] primaryOpcodes = { /* OPCD Decoder */ /* 0x00 */new X86_Add_OpcodeDecoder(8, true, 0, true), // 8bit, has - // ModRM, no imm, - // rm is dest + // ModRM, no imm, + // rm is dest /* 0x01 */new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x02 */new X86_Add_OpcodeDecoder(8, true, 0, false),// 8bit, has - // ModRM, no imm, - // rm is src + // ModRM, no imm, + // rm is src /* 0x03 */new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x04 */new X86_Add_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, - // 8bit imm + // 8bit imm /* 0x05 */new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false),// 16/32bit, no ModRM, 16/32bit imm /* 0x06 */null, /* 0x07 */null, /* 0x08 */new X86_Or_OpcodeDecoder(8, true, 0, true), // 8bit, has ModRM, - // no imm, rm is - // dest + // no imm, rm is + // dest /* 0x09 */new X86_Or_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x0A */new X86_Or_OpcodeDecoder(8, true, 0, false),// 8bit, has ModRM, - // no imm, rm is src + // no imm, rm is src /* 0x0B */new X86_Or_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x0C */new X86_Or_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, - // 8bit imm + // 8bit imm /* 0x0D */new X86_Or_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false),// 16/32bit, no ModRM, 16/32bit imm /* 0x0E */null, @@ -151,106 +151,106 @@ /* 0x1F */null, /* 0x20 */new X86_And_OpcodeDecoder(8, true, 0, true), // 8bit, has - // ModRM, no imm, - // rm is dest + // ModRM, no imm, + // rm is dest /* 0x21 */new X86_And_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x22 */new X86_And_OpcodeDecoder(8, true, 0, false),// 8bit, has - // ModRM, no imm, - // rm is src + // ModRM, no imm, + // rm is src /* 0x23 */new X86_And_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x24 */new X86_And_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, - // 8bit imm + // 8bit imm /* 0x25 */new X86_And_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false),// 16/32bit, no ModRM, 16/32bit imm /* 0x26 */new X86_ES_SegmentOverride_PrefixDecoder(), /* 0x27 */null, /* 0x28 */new X86_Sub_OpcodeDecoder(8, true, 0, true), // 8bit, has - // ModRM, no imm, - // rm is dest + // ModRM, no imm, + // rm is dest /* 0x29 */new X86_Sub_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x2A */new X86_Sub_OpcodeDecoder(8, true, 0, false),// 8bit, has - // ModRM, no imm, - // rm is src + // ModRM, no imm, + // rm is src /* 0x2B */new X86_Sub_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x2C */new X86_Sub_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, - // 8bit imm + // 8bit imm /* 0x2D */new X86_Sub_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false),// 16/32bit, no ModRM, 16/32bit imm /* 0x2E */new X86_CS_SegmentOverride_PrefixDecoder(), /* 0x2F */null, /* 0x30 */new X86_Xor_OpcodeDecoder(8, true, 0, true), // 8bit, has - // ModRM, no imm, - // rm is dest + // ModRM, no imm, + // rm is dest /* 0x31 */new X86_Xor_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x32 */new X86_Xor_OpcodeDecoder(8, true, 0, false),// 8bit, has - // ModRM, no imm, - // rm is src + // ModRM, no imm, + // rm is src /* 0x33 */new X86_Xor_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x34 */new X86_Xor_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, - // 8bit imm + // 8bit imm /* 0x35 */new X86_Xor_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false),// 16/32bit, no ModRM, 16/32bit imm /* 0x36 */new X86_SS_SegmentOverride_PrefixDecoder(), /* 0x37 */null, /* 0x38 */new X86_Cmp_OpcodeDecoder(8, true, 0, true), // 8bit, has - // ModRM, no imm, - // rm is dest + // ModRM, no imm, + // rm is dest /* 0x39 */new X86_Cmp_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x3A */new X86_Cmp_OpcodeDecoder(8, true, 0, false),// 8bit, has - // ModRM, no imm, - // rm is src + // ModRM, no imm, + // rm is src /* 0x3B */new X86_Cmp_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x3C */new X86_Cmp_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, - // 8bit imm + // 8bit imm /* 0x3D */new X86_Cmp_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false),// 16/32bit, no ModRM, 16/32bit imm /* 0x3E */new X86_DS_SegmentOverride_PrefixDecoder(), @@ -316,7 +316,7 @@ /* 0x66 */new X86_OperandSizeOverride_PrefixDecoder(), /* 0x67 */new X86_AddressSizeOverride_PrefixDecoder(), /* 0x68 */new X86_Push_OpcodeDecoder(_16BIT ? -16 : -32), // Push 16/32bit - // immediate + // immediate /* 0x69 */null, /* 0x6A */new X86_Push_OpcodeDecoder(-8), // Push 8bit immediate /* 0x6B */null, @@ -343,13 +343,13 @@ /* 0x7F */new X86_Jcc_OpcodeDecoder(GREATER, 8), /* 0x80 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 8bit, - // ModRM, - // 8bit - // imm, - // rm - // is - // dest - new X86_Add_OpcodeDecoder(8, true, 8, true),// 0 + // ModRM, + // 8bit + // imm, + // rm + // is + // dest + new X86_Add_OpcodeDecoder(8, true, 8, true),// 0 new X86_Or_OpcodeDecoder(8, true, 8, true),// 1 new X86_Adc_OpcodeDecoder(8, true, 8, true),// 2 new X86_Sbb_OpcodeDecoder(8, true, 8, true),// 3 @@ -359,12 +359,12 @@ new X86_Cmp_OpcodeDecoder(8, true, 8, true) // 7 }), /* 0x81 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 16/32bit, - // ModRM, - // 16/32bit - // imm, - // rm - // is - // dest + // ModRM, + // 16/32bit + // imm, + // rm + // is + // dest new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, _16BIT ? 16 : 32, true),// 0 new X86_Or_OpcodeDecoder(_16BIT ? 16 : 32, true, @@ -384,13 +384,13 @@ }), /* 0x82 */null, /* 0x83 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 16/32bit, - // ModRM, - // 8bit - // imm, - // rm - // is - // dest - new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true),// 0 + // ModRM, + // 8bit + // imm, + // rm + // is + // dest + new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true),// 0 new X86_Or_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true),// 1 new X86_Adc_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true),// 2 new X86_Sbb_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true),// 3 @@ -400,33 +400,33 @@ new X86_Cmp_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true) // 7 }), /* 0x84 */new X86_Test_OpcodeDecoder(8, true, 0), // 8bit, has ModRM, no - // imm + // imm /* 0x85 */new X86_Test_OpcodeDecoder(_16BIT ? 16 : 32, true, 0), // 16/32bit,has - // ModRM, - // no - // imm + // ModRM, + // no + // imm /* 0x86 */null, /* 0x87 */null, /* 0x88 */new X86_Mov_OpcodeDecoder(8, true, 0, true), // 8bit, has - // ModRM, no imm, - // rm is dest + // ModRM, no imm, + // rm is dest /* 0x89 */new X86_Mov_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // dest + // ModRM, + // no + // imm, + // rm + // is + // dest /* 0x8A */new X86_Mov_OpcodeDecoder(8, true, 0, false),// 8bit, has - // ModRM, no imm, - // rm is src + // ModRM, no imm, + // rm is src /* 0x8B */new X86_Mov_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + // ModRM, + // no + // imm, + // rm + // is + // src /* 0x8C */null, /* 0x8D */new X86_Lea_OpcodeDecoder(), /* 0x8E */null, @@ -460,12 +460,12 @@ /* 0xA0 */new X86_Mov_OpcodeDecoder(8, true), // mov al, [disp8] /* 0xA1 */new X86_Mov_OpcodeDecoder(_16BIT ? 16 : 32, false),// mov - // [e]ax, - // [disp(16|32)] + // [e]ax, + // [disp(16|32)] /* 0xA2 */new X86_Mov_OpcodeDecoder(8, false), // mov [disp8], al /* 0xA3 */new X86_Mov_OpcodeDecoder(_16BIT ? 16 : 32, true), // mov - // [disp(16|32)], - // eax + // [disp(16|32)], + // eax /* 0xA4 */null, /* 0xA5 */null, /* 0xA6 */null, @@ -488,21 +488,21 @@ /* 0xB6 */new X86_Mov_OpcodeDecoder(6, 8), // reg, 8bit immediate /* 0xB7 */new X86_Mov_OpcodeDecoder(7, 8), // reg, 8bit immediate /* 0xB8 */new X86_Mov_OpcodeDecoder(0, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xB9 */new X86_Mov_OpcodeDecoder(1, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xBA */new X86_Mov_OpcodeDecoder(2, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xBB */new X86_Mov_OpcodeDecoder(3, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xBC */new X86_Mov_OpcodeDecoder(4, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xBD */new X86_Mov_OpcodeDecoder(5, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xBE */new X86_Mov_OpcodeDecoder(6, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xBF */new X86_Mov_OpcodeDecoder(7, _16BIT ? 16 : 32), // reg, 16/32bit - // immediate + // immediate /* 0xC0 */null, /* 0xC1 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] { @@ -511,43 +511,43 @@ null, // 2 null, // 3 new X86_Shl_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true), // 4 - - // 16/32bit, - // has - // ModRM, - // 8bit - // imm, rm - // is dest + // 16/32bit, + // has + // ModRM, + // 8bit + // imm, rm + // is dest new X86_Ushr_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true),// 5 - - // 16/32bit, - // has - // ModRM, - // 8bit - // imm, rm - // is dest + // 16/32bit, + // has + // ModRM, + // 8bit + // imm, rm + // is dest null, // 6 new X86_Shr_OpcodeDecoder(_16BIT ? 16 : 32, true, 8, true) // 7 - - // 16/32bit, - // has - // ModRM, - // 8bit - // imm, rm - // is dest + // 16/32bit, + // has + // ModRM, + // 8bit + // imm, rm + // is dest }), /* 0xC2 */new X86_Ret_OpcodeDecoder(false, 16), // near return, 16bit - // immediate + // immediate /* 0xC3 */new X86_Ret_OpcodeDecoder(false, 0), // near return, no - // immediate + // immediate /* 0xC4 */null, /* 0xC5 */null, /* 0xC6 */new X86_Mov_OpcodeDecoder(8, true, 8, true), // 8bit, has - // ModRM, 8bit - // imm, rm is dest + // ModRM, 8bit + // imm, rm is dest /* 0xC7 */new X86_Mov_OpcodeDecoder(_16BIT ? 16 : 32, true, _16BIT ? 16 : 32, true), // 16/32bit, has ModRM, 16/32bit imm, rm is dest /* 0xC8 */null, /* 0xC9 */new X86_Leave_OpcodeDecoder(), /* 0xCA */new X86_Ret_OpcodeDecoder(true, 16), // far return, 16bit - // immediate + // immediate /* 0xCB */new X86_Ret_OpcodeDecoder(true, 0), // far return, no immediate /* 0xCC */null, /* 0xCD */new X86_Int_OpcodeDecoder(), @@ -563,27 +563,27 @@ null, // 2 null, // 3 new X86_Shl_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true), // 4 - - // 16/32bit, - // has - // ModRM, - // no imm, - // rm is - // dest + // 16/32bit, + // has + // ModRM, + // no imm, + // rm is + // dest new X86_Ushr_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true),// 5 - - // 16/32bit, - // has - // ModRM, - // no imm, - // rm is - // dest + // 16/32bit, + // has + // ModRM, + // no imm, + // rm is + // dest null, // 6 new X86_Shr_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, true) // 7 - - // 16/32bit, - // has - // ModRM, - // no imm, - // rm is - // dest + // 16/32bit, + // has + // ModRM, + // no imm, + // rm is + // dest }), /* 0xD4 */null, /* 0xD5 */null, @@ -618,12 +618,12 @@ /* 0xE8 */new X86_Call_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 : 32, false), // 16/32bit, no ModRM, 16/32bit imm /* 0xE9 */new X86_Jmp_OpcodeDecoder(false, _16BIT ? 16 : 32), // relative - // jump + - // 16/32bit - // immediate + // jump + + // 16/32bit + // immediate /* 0xEA */null, /* 0xEB */new X86_Jmp_OpcodeDecoder(false, 8), // relative jump + 8bit - // immediate + // immediate /* 0xEC */null, /* 0xED */null, /* 0xEE */null, @@ -636,13 +636,13 @@ /* 0xF4 */null, /* 0xF5 */null, /* 0xF6 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 8bit, - // ModRM, - // 8bit - // imm, - // rm - // is - // dest - new X86_Test_OpcodeDecoder(8, true, 8), // 0 + // ModRM, + // 8bit + // imm, + // rm + // is + // dest + new X86_Test_OpcodeDecoder(8, true, 8), // 0 null, // 1 new X86_Not_OpcodeDecoder(8), // 2 - 8bit new X86_Neg_OpcodeDecoder(8), // 3 - 8bit @@ -652,13 +652,14 @@ null // 7 }), /* 0xF7 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 16/32bit, - // ModRM, - // 16/32bit - // imm, - // rm - // is - // dest - new X86_Test_OpcodeDecoder(_16BIT ? 16 : 32, true, _16BIT ? 16 : 32),// 0 + // ModRM, + // 16/32bit + // imm, + // rm + // is + // dest + new X86_Test_OpcodeDecoder(_16BIT ? 16 : 32, true, _16BIT ? 16 + : 32),// 0 null, // 1 new X86_Not_OpcodeDecoder(_16BIT ? 16 : 32), // 2 - 16/32bit new X86_Neg_OpcodeDecoder(_16BIT ? 16 : 32), // 3 - 16/32bit @@ -678,10 +679,10 @@ new X86_Inc_OpcodeDecoder(-1), // 0 - Inc of memory operand null, // 1 new X86_Call_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false), // 2 - - // 16/32bit, - // ModRM, - // no - // imm + // 16/32bit, + // ModRM, + // no + // imm null, // 3 new X86_Jmp_OpcodeDecoder(true, 0), // 4 - near absolute jump to ModRM null, // 5 @@ -730,11 +731,8 @@ /** * Disassemble a single instruction - * - * @param ps - * the process space of the translation - * @param pc - * the address of the instruction to translate + * @param ps the process space of the translation + * @param pc the address of the instruction to translate * @return the string for this instruction */ public String disassemble(ProcessSpace ps, int pc) { @@ -743,13 +741,9 @@ /** * Translate a single instruction - * - * @param translationHelper - * the object containing the translation sequence - * @param ps - * the process space of the translation - * @param pc - * the address of the instruction to translate + * @param translationHelper the object containing the translation sequence + * @param ps the process space of the translation + * @param pc the address of the instruction to translate * @return the address of the next instruction or -1 if this instruction has * branched to the end of the trace */ @@ -761,13 +755,9 @@ /** * Translate a single instruction which doesn't already have a decoder - * - * @param translationHelper - * the object containing the translation sequence - * @param ps - * the process space of the translation - * @param pc - * the address of the instruction to translate + * @param translationHelper the object containing the translation sequence + * @param ps the process space of the translation + * @param pc the address of the instruction to translate * @return the address of the next instruction or -1 if this instruction has * branched to the end of the trace */ @@ -782,9 +772,7 @@ /** * Interpret a single instruction - * - * @param ps - * the process space of the interpretation, contains the fetched + * @param ps the process space of the interpretation, contains the fetched * instruction and instruction address * @return the next instruction interpreter */ @@ -899,13 +887,9 @@ /** * Translate a single instruction - * - * @param translationHelper - * the object containing the translation sequence - * @param ps - * the process space of the translation - * @param pc - * the address of the instruction to translate + * @param translationHelper the object containing the translation sequence + * @param ps the process space of the translation + * @param pc the address of the instruction to translate * @return the address of the next instruction or -1 if this instruction has * branched to the end of the trace */ @@ -926,11 +910,8 @@ /** * Disassemble a single instruction - * - * @param ps - * the process space of the translation - * @param pc - * the address of the instruction to translate + * @param ps the process space of the translation + * @param pc the address of the instruction to translate * @return the string for this instruction */ public String disassemble(ProcessSpace ps, int pc) { @@ -1350,18 +1331,15 @@ /** * Constructor - * - * @param operandSize - * size of register/mem/immediate operands - * @param hasModRM - * does a ModRM byte follow the opcode possibly giving more + * @param operandSize size of register/mem/immediate operands + * @param hasModRM does a ModRM byte follow the opcode possibly giving more * information on the opcode as well as defining register and memory * operands? - * @param immediateSize - * the size in bits of any immediate or 0 if no immediate value - * @param isMemoryOperandDestination - * is the destination/result of this instruction a memory or register - * in the case that there's a ModRM byte + * @param immediateSize the size in bits of any immediate or 0 if no immediate + * value + * @param isMemoryOperandDestination is the destination/result of this + * instruction a memory or register in the case that there's a ModRM + * byte */ X86_OpcodeDecoder(int operandSize, boolean hasModRM, int immediateSize, boolean isMemoryOperandDestination) { @@ -1377,28 +1355,24 @@ /** * Constructor - * - * @param operandSize - * size of register/mem/immediate operands - * @param hasModRM - * does a ModRM byte follow the opcode possibly giving more + * @param operandSize size of register/mem/immediate operands + * @param hasModRM does a ModRM byte follow the opcode possibly giving more * information on the opcode as well as defining register and memory * operands? - * @param immediateSize - * the size in bits of any immediate or 0 if no immediate value - * @param isMemoryOperandDestination - * is the destination/result of this instruction a memory or register - * in the case that there's a ModRM byte - * @param register - * override EAX as the implicit register for an instruction not - * specifying modrm + * @param immediateSize the size in bits of any immediate or 0 if no immediate + * value + * @param isMemoryOperandDestination is the destination/result of this + * instruction a memory or register in the case that there's a ModRM + * byte + * @param register override EAX as the implicit register for an instruction + * not specifying modrm */ X86_OpcodeDecoder(int operandSize, boolean hasModRM, int immediateSize, boolean isMemoryOperandDestination, int register) { this.operandSize = operandSize; this.hasModRM = hasModRM; this.modRMhasOpcode = true; // override the register to show that the reg of - // the modrm is invalid + // the modrm is invalid this.immediateSize = immediateSize; this.isMemoryOperandDestination = isMemoryOperandDestination; this.register = register; @@ -1408,21 +1382,17 @@ /** * Constructor - * - * @param operandSize - * size of register/mem/immediate operands - * @param hasModRM - * does a ModRM byte follow the opcode possibly giving more + * @param operandSize size of register/mem/immediate operands + * @param hasModRM does a ModRM byte follow the opcode possibly giving more * information on the opcode as well as defining register and memory * operands? - * @param immediateSize - * the size in bits of any immediate or 0 if no immediate value - * @param isMemoryOperandDestination - * is the destination/result of this instruction a memory or register - * in the case that there's a ModRM byte - * @param discardResult - * should the result of the operation be written to the destination - * or just the flags modified? + * @param immediateSize the size in bits of any immediate or 0 if no immediate + * value + * @param isMemoryOperandDestination is the destination/result of this + * instruction a memory or register in the case that there's a ModRM + * byte + * @param discardResult should the result of the operation be written to the + * destination or just the flags modified? */ X86_OpcodeDecoder(int operandSize, boolean hasModRM, int immediateSize, boolean isMemoryOperandDestination, boolean discardResult) { @@ -1438,14 +1408,12 @@ /** * Constructor - * - * @param operandSize - * size of register/mem/immediate operands - * @param isMemoryOperandDestination - * is the destination/result of this instruction a memory or register - * in the case that there's a ModRM byte - * @param displacementSize - * a size for a displacement always present regardless of modrm + * @param operandSize size of register/mem/immediate operands + * @param isMemoryOperandDestination is the destination/result of this + * instruction a memory or register in the case that there's a ModRM + * byte + * @param displacementSize a size for a displacement always present regardless + * of modrm */ X86_OpcodeDecoder(int operandSize, boolean isMemoryOperandDestination, int displacementSize) { @@ -1627,32 +1595,20 @@ /** * Perform the actual translation - * * @param translationHelper * @param ps * @param lazy - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected int translate(X862IR translationHelper, ProcessSpace ps, X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, @@ -1808,30 +1764,18 @@ /** * Disassemble the opcode - * * @param ps - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected String disassemble(ProcessSpace ps, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, int displacement, @@ -2111,7 +2055,7 @@ /* 0xB4 */null, /* 0xB5 */null, /* 0xB6 */new X86_MovZX_OpcodeDecoder(_16BIT ? 16 : 32, 8), // dest 16/32bit, - // src 8bit + // src 8bit /* 0xB7 */new X86_MovZX_OpcodeDecoder(32, 16), // dest 32bit, src 16bit /* 0xB8 */null, /* 0xB9 */null, @@ -2120,8 +2064,8 @@ /* 0xBC */null, /* 0xBD */null, /* 0xBE */new X86_MovSX_OpcodeDecoder(_16BIT ? 16 : 32, 8), // dest - // 16/32bit, - // src 8bit + // 16/32bit, + // src 8bit /* 0xBF */new X86_MovSX_OpcodeDecoder(32, 16), // dest 32bit, src 16bit /* 0xC0 */null, @@ -2195,10 +2139,11 @@ /** * Utility to get a decoder for a particular opcode */ - protected static X86_OpcodeDecoder secondaryOpcodeLookup(int opcode) { + protected static X86_InstructionDecoder secondaryOpcodeLookup(int opcode) { if (secondaryOpcodes[opcode] == null) { - throw new Error("Secondary Opcode 0x" + Integer.toHexString(opcode) + System.out.println("Secondary Opcode 0x" + Integer.toHexString(opcode) + " not found"); + return badInstructionDecoder; } else { return secondaryOpcodes[opcode]; } @@ -2764,9 +2709,7 @@ class X86_Pop_OpcodeDecoder extends X86_OpcodeDecoder { /** * Constructor, {@see X86_OpcodeDecoder} - * - * @param reg - * the register to pop into or -1 to show that the destination is a + * @param reg the register to pop into or -1 to show that the destination is a * memory operand */ X86_Pop_OpcodeDecoder(int reg) { @@ -2780,32 +2723,20 @@ /** * Perform the actual translation - * * @param translationHelper * @param ps * @param lazy - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected int translate(X862IR translationHelper, ProcessSpace ps, X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, @@ -2853,30 +2784,18 @@ /** * Disassemble the opcode - * * @param ps - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immedate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immedate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected String disassemble(ProcessSpace ps, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, int displacement, @@ -2913,10 +2832,8 @@ class X86_Push_OpcodeDecoder extends X86_OpcodeDecoder { /** * Constructor, {@see X86_OpcodeDecoder} - * - * @param reg - * the register to push into, or -1 to show that the destination is a - * memory operand, or -8/-16/-32 to show that this is an immediate + * @param reg the register to push into, or -1 to show that the destination is + * a memory operand, or -8/-16/-32 to show that this is an immediate * push of the appropriate size */ X86_Push_OpcodeDecoder(int reg) { @@ -2930,32 +2847,20 @@ /** * Perform the actual translation - * * @param translationHelper * @param ps * @param lazy - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected int translate(X862IR translationHelper, ProcessSpace ps, X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, @@ -3007,30 +2912,18 @@ /** * Disassemble the opcode - * * @param ps - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immedate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immedate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected String disassemble(ProcessSpace ps, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, int displacement, @@ -3085,32 +2978,20 @@ /** * Perform the actual translation - * * @param translationHelper * @param ps * @param lazy - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected int translate(X862IR translationHelper, ProcessSpace ps, X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, @@ -3148,30 +3029,18 @@ /** * Disassemble the opcode - * * @param ps - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immedate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immedate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected String disassemble(ProcessSpace ps, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, int displacement, @@ -3196,32 +3065,20 @@ /** * Perform the actual translation - * * @param translationHelper * @param ps * @param lazy - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * a group4 prefix decoder or null - * @param prefix5 - * a group5 prefix decoder or null + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null */ protected int translate(X862IR translationHelper, ProcessSpace ps, X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, @@ -3282,30 +3139,18 @@ /** * Disassemble the opcode - * * @param ps - * @param pc - * the address of the instruction being translated - * @param modrm - * the decoder for any modrm part of the instruction - * @param sib - * the sib decoder for any sib part of the instruction - * @param displacement - * any displacement to be added to the modrm - * @param immediateSize - * what size is the immediate value - * @param immediate - * if immediateSize > 0 then this is the immediate value - * @param length - * the length of the instruction - * @param prefix2 - * a group2 prefix decoder or null - * @param prefix3 - * a group3 prefix decoder or null - * @param prefix4 - * ... [truncated message content] |
From: <cap...@us...> - 2007-04-18 14:24:40
|
Revision: 63 http://svn.sourceforge.net/pearcolator/?rev=63&view=rev Author: captain5050 Date: 2007-04-18 07:24:41 -0700 (Wed, 18 Apr 2007) Log Message: ----------- Support for div and imul Modified Paths: -------------- src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java Modified: src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java =================================================================== --- src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java 2007-04-18 14:24:25 UTC (rev 62) +++ src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java 2007-04-18 14:24:41 UTC (rev 63) @@ -95,13 +95,8 @@ /* 0x02 */new X86_Add_OpcodeDecoder(8, true, 0, false),// 8bit, has // ModRM, no imm, // rm is src - /* 0x03 */new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false),// 16/32bit,has - // ModRM, - // no - // imm, - // rm - // is - // src + /* 0x03 */new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, true, 0, false), + // 16/32bit, has ModRM, no imm, rm is src /* 0x04 */new X86_Add_OpcodeDecoder(8, false, 8, false),// 8bit, no ModRM, // 8bit imm /* 0x05 */new X86_Add_OpcodeDecoder(_16BIT ? 16 : 32, false, _16BIT ? 16 @@ -637,19 +632,14 @@ /* 0xF4 */null, /* 0xF5 */null, /* 0xF6 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 8bit, - // ModRM, - // 8bit - // imm, - // rm - // is - // dest + // ModRM, 8bit imm, rm is dest new X86_Test_OpcodeDecoder(8, true, 8), // 0 null, // 1 new X86_Not_OpcodeDecoder(8), // 2 - 8bit new X86_Neg_OpcodeDecoder(8), // 3 - 8bit - new X86_Mul_OpcodeDecoder(8), // 3 - 8bit + new X86_Mul_OpcodeDecoder(8), // 4 - 8bit null, // 5 - null, // 6 + new X86_Div_OpcodeDecoder(8), // 6 - 8bit null // 7 }), /* 0xF7 */new X86_OpcodeInModRMReg_Decoder(new X86_OpcodeDecoder[] {// 16/32bit, @@ -666,7 +656,7 @@ new X86_Neg_OpcodeDecoder(_16BIT ? 16 : 32), // 3 - 16/32bit new X86_Mul_OpcodeDecoder(_16BIT ? 16 : 32), // 4 - 16/32bit null, // 5 - null, // 6 + new X86_Div_OpcodeDecoder(_16BIT ? 16 : 32), // 6 - 16/32bit null // 7 }), /* 0xF8 */null, @@ -764,12 +754,9 @@ */ public static int translateInstruction(X862IR translationHelper, ProcessSpace ps, X86_Laziness lazy, int pc) { - System.err.println("Translating "+pc); X86_InstructionDecoder decoder = getDecoder(ps, pc); if (DBT_Options.debugInstr) { - System.err.println("Disassembling "+pc); System.err.println(decoder.disassemble(ps, pc)); - System.err.println("After disassembling "+pc); } return decoder.translate(translationHelper, ps, lazy, pc); } @@ -2073,7 +2060,8 @@ /* 0xAC */null, /* 0xAD */null, /* 0xAE */null, - /* 0xAF */null, + /* 0xAF */new X86_Imul_OpcodeDecoder(_16BIT ? 16 : 32, 0, false), + // 16/32bit, no imm, not edx:eax /* 0xB0 */null, /* 0xB1 */null, @@ -2081,87 +2069,84 @@ /* 0xB3 */null, /* 0xB4 */null, /* 0xB5 */null, - /* 0xB6 */new X86_MovZX_OpcodeDecoder(_16BIT ? 16 : 32, 8), // dest 16/32bit, - // src 8bit - /* 0xB7 */new X86_MovZX_OpcodeDecoder(32, 16), // dest 32bit, src 16bit - /* 0xB8 */null, - /* 0xB9 */null, - /* 0xBA */null, - /* 0xBB */null, - /* 0xBC */null, - /* 0xBD */null, - /* 0xBE */new X86_MovSX_OpcodeDecoder(_16BIT ? 16 : 32, 8), // dest - // 16/32bit, - // src 8bit - /* 0xBF */new X86_MovSX_OpcodeDecoder(32, 16), // dest 32bit, src 16bit + /* 0xB6 */new X86_MovZX_OpcodeDecoder(_16BIT ? 16 : 32, 8), // dest 16/32bit, src 8bit + /* 0xB7 */new X86_MovZX_OpcodeDecoder(32, 16), // dest 32bit, src 16bit + /* 0xB8 */null, + /* 0xB9 */null, + /* 0xBA */null, + /* 0xBB */null, + /* 0xBC */null, + /* 0xBD */null, + /* 0xBE */new X86_MovSX_OpcodeDecoder(_16BIT ? 16 : 32, 8), // dest 16/32bit, src 8bit + /* 0xBF */new X86_MovSX_OpcodeDecoder(32, 16), // dest 32bit, src 16bit - /* 0xC0 */null, - /* 0xC1 */null, - /* 0xC2 */null, - /* 0xC3 */null, - /* 0xC4 */null, - /* 0xC5 */null, - /* 0xC6 */null, - /* 0xC7 */null, - /* 0xC8 */null, - /* 0xC9 */null, - /* 0xCA */null, - /* 0xCB */null, - /* 0xCC */null, - /* 0xCD */null, - /* 0xCE */null, - /* 0xCF */null, + /* 0xC0 */null, + /* 0xC1 */null, + /* 0xC2 */null, + /* 0xC3 */null, + /* 0xC4 */null, + /* 0xC5 */null, + /* 0xC6 */null, + /* 0xC7 */null, + /* 0xC8 */null, + /* 0xC9 */null, + /* 0xCA */null, + /* 0xCB */null, + /* 0xCC */null, + /* 0xCD */null, + /* 0xCE */null, + /* 0xCF */null, - /* 0xD0 */null, - /* 0xD1 */null, - /* 0xD2 */null, - /* 0xD3 */null, - /* 0xD4 */null, - /* 0xD5 */null, - /* 0xD6 */null, - /* 0xD7 */null, - /* 0xD8 */null, - /* 0xD9 */null, - /* 0xDA */null, - /* 0xDB */null, - /* 0xDC */null, - /* 0xDD */null, - /* 0xDE */null, - /* 0xDF */null, + /* 0xD0 */null, + /* 0xD1 */null, + /* 0xD2 */null, + /* 0xD3 */null, + /* 0xD4 */null, + /* 0xD5 */null, + /* 0xD6 */null, + /* 0xD7 */null, + /* 0xD8 */null, + /* 0xD9 */null, + /* 0xDA */null, + /* 0xDB */null, + /* 0xDC */null, + /* 0xDD */null, + /* 0xDE */null, + /* 0xDF */null, - /* 0xE0 */null, - /* 0xE1 */null, - /* 0xE2 */null, - /* 0xE3 */null, - /* 0xE4 */null, - /* 0xE5 */null, - /* 0xE6 */null, - /* 0xE7 */null, - /* 0xE8 */null, - /* 0xE9 */null, - /* 0xEA */null, - /* 0xEB */null, - /* 0xEC */null, - /* 0xED */null, - /* 0xEE */null, - /* 0xEF */null, + /* 0xE0 */null, + /* 0xE1 */null, + /* 0xE2 */null, + /* 0xE3 */null, + /* 0xE4 */null, + /* 0xE5 */null, + /* 0xE6 */null, + /* 0xE7 */null, + /* 0xE8 */null, + /* 0xE9 */null, + /* 0xEA */null, + /* 0xEB */null, + /* 0xEC */null, + /* 0xED */null, + /* 0xEE */null, + /* 0xEF */null, - /* 0xF0 */null, - /* 0xF1 */null, - /* 0xF2 */null, - /* 0xF3 */null, - /* 0xF4 */null, - /* 0xF5 */null, - /* 0xF6 */null, - /* 0xF7 */null, - /* 0xF8 */null, - /* 0xF9 */null, - /* 0xFA */null, - /* 0xFB */null, - /* 0xFC */null, - /* 0xFD */null, - /* 0xFE */null, - /* 0xFF */null }; + /* 0xF0 */null, + /* 0xF1 */null, + /* 0xF2 */null, + /* 0xF3 */null, + /* 0xF4 */null, + /* 0xF5 */null, + /* 0xF6 */null, + /* 0xF7 */null, + /* 0xF8 */null, + /* 0xF9 */null, + /* 0xFA */null, + /* 0xFB */null, + /* 0xFC */null, + /* 0xFD */null, + /* 0xFE */null, + /* 0xFF */null }; /** * Utility to get a decoder for a particular opcode @@ -3510,6 +3495,15 @@ rhsOp1 = translationHelper.getOverflowFlag(); condOp1 = OPT_ConditionOperand.EQUAL(); break; + case GREATER: + operator = BOOLEAN_CMP2_INT_AND; + lhsOp1 = translationHelper.getZeroFlag(); + rhsOp1 = new OPT_IntConstantOperand(0); + condOp1 = OPT_ConditionOperand.EQUAL(); + lhsOp2 = translationHelper.getSignFlag(); + rhsOp2 = translationHelper.getOverflowFlag(); + condOp2 = OPT_ConditionOperand.EQUAL(); + break; default: TODO(); } @@ -5362,6 +5356,9 @@ } else { addressSize = _16BIT ? 32 : 16; } + if (operandSize != 32) { + TODO(); + } // longs to perform the mul in OPT_RegisterOperand tempLong1 = translationHelper.getTempLong(0); OPT_RegisterOperand tempLong2 = translationHelper.getTempLong(1); @@ -5438,6 +5435,275 @@ } /** + * The decoder for the Imul opcode. This opcode has 3 forms: + * EDX:EAX is the destination, + * reg is the destination with either reg/mem/immediate as a source, + * or reg is the destination with either reg/mem as a source and an immediate + * as the second source. + */ +class X86_Imul_OpcodeDecoder extends X86_OpcodeDecoder { + /** + * Is EDX:EAX implicitly the destination of this instruction + */ + final boolean isAccumulatorDestination; + /** + * Constructor, {@see X86_OpcodeDecoder} + */ + X86_Imul_OpcodeDecoder(int size, int immediateSize, boolean isAccumulatorDestination) { + super(size, true, immediateSize, false); + this.isAccumulatorDestination = isAccumulatorDestination; + } + + /** + * Perform the actual translation + * @param translationHelper + * @param ps + * @param lazy + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null + */ + protected int translate(X862IR translationHelper, ProcessSpace ps, + X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, + int displacement, int immediateSize, int immediate, int length, + X86_Group2PrefixDecoder prefix2, X86_Group3PrefixDecoder prefix3, + X86_Group4PrefixDecoder prefix4, X86_Group5PrefixDecoder prefix5) { + int operandSize; + if (prefix3 == null) { + operandSize = this.operandSize; + } else { + switch (this.operandSize) { + case 32: + operandSize = 16; + break; + case 16: + operandSize = 32; + break; + default: + operandSize = -1; + DBT_OptimizingCompilerException.UNREACHABLE(); + } + } + int addressSize; + if (prefix4 == null) { + addressSize = _16BIT ? 16 : 32; + } else { + addressSize = _16BIT ? 32 : 16; + } + + X86_DecodedOperand destination = null; + X86_DecodedOperand source1, source2 = null; + + source1 = modrm.getRM(translationHelper, lazy, sib, displacement, + operandSize, addressSize, + (prefix2 != null) ? prefix2.getSegment() : X86_Registers.DS); + + if (!isAccumulatorDestination) { + destination = modrm.getReg(operandSize); + if (immediateSize > 0) { + // dest = source1 * imm + source2 = X86_DecodedOperand.getImmediate(immediate); + } else { + // dest = dest * source1; + source2 = destination; + } + } + + if (operandSize != 32) { + TODO(); + } + + OPT_RegisterOperand sourceOp1 = translationHelper.getTempInt(1); + source1.readToRegister(translationHelper, lazy, sourceOp1); + if (isAccumulatorDestination) { + // 64bit by 32bit multiply result to go in edx:eax + OPT_RegisterOperand longSourceOp1 = translationHelper.getTempLong(1); + translationHelper.appendInstructionToCurrentBlock(Unary.create(INT_2LONG, + longSourceOp1, sourceOp1.copyRO())); + TODO(); + } else { + OPT_RegisterOperand sourceOp2 = translationHelper.getTempInt(2); + source2.readToRegister(translationHelper, lazy, sourceOp2); + OPT_RegisterOperand temp = translationHelper.getTempInt(3); + translationHelper.appendInstructionToCurrentBlock(Binary.create(INT_MUL, + temp, sourceOp1.copyRO(), sourceOp2.copyRO())); + destination.writeValue(translationHelper, lazy, temp.copyRO()); + OPT_RegisterOperand carry = translationHelper.getCarryFlag(); + translationHelper.appendInstructionToCurrentBlock(BooleanCmp.create( + BOOLEAN_CMP_INT, carry, sourceOp1.copyRO(), sourceOp2.copyRO(), OPT_ConditionOperand + .OVERFLOW_FROM_MUL(), new OPT_BranchProfileOperand())); + OPT_RegisterOperand overflow = translationHelper.getOverflowFlag(); + translationHelper.appendInstructionToCurrentBlock( + Move.create(INT_MOVE, overflow, carry.copyRO())); + } + return pc + length; + } + + /** + * Return "imul" + */ + String getOperatorString() { + return "imul"; + } +} + +/** + * The decoder for the Div opcode + */ +class X86_Div_OpcodeDecoder extends X86_OpcodeDecoder { + /** + * Constructor, {@see X86_OpcodeDecoder} + * @param operandSize + */ + X86_Div_OpcodeDecoder(int operandSize) { + super(operandSize, // operandSize + true, // hasModRM, + 0, // immediateSize + true // isMemoryOperandDestination + ); + } + + /** + * Perform the actual translation + * @param translationHelper + * @param ps + * @param lazy + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immediate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null + */ + protected int translate(X862IR translationHelper, ProcessSpace ps, + X86_Laziness lazy, int pc, X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, + int displacement, int immediateSize, int immediate, int length, + X86_Group2PrefixDecoder prefix2, X86_Group3PrefixDecoder prefix3, + X86_Group4PrefixDecoder prefix4, X86_Group5PrefixDecoder prefix5) { + int operandSize; + if (prefix3 == null) { + operandSize = this.operandSize; + } else if (this.operandSize == 32) { + operandSize = 16; + } else { + operandSize = 32; + } + int addressSize; + if (prefix4 == null) { + addressSize = _16BIT ? 16 : 32; + } else { + addressSize = _16BIT ? 32 : 16; + } + if (operandSize != 32) { + TODO(); + } + // longs to perform the div in + OPT_RegisterOperand tempLong1 = translationHelper.getTempLong(0); + OPT_RegisterOperand tempLong2 = translationHelper.getTempLong(1); + // Create EDX:EAX in tempLong1 + OPT_RegisterOperand edx = translationHelper.getGPRegister(lazy, + X86_Registers.EDX, operandSize); + OPT_RegisterOperand eax = translationHelper.getGPRegister(lazy, + X86_Registers.EAX, operandSize); + translationHelper.appendInstructionToCurrentBlock(Unary.create(INT_2LONG, + tempLong1, edx)); + translationHelper.appendInstructionToCurrentBlock(Unary.create(INT_2LONG, + tempLong2, eax)); + translationHelper.appendInstructionToCurrentBlock(Binary.create(LONG_SHL, + tempLong1.copyRO(), tempLong1.copyRO(), new OPT_IntConstantOperand(32))); + translationHelper.appendInstructionToCurrentBlock(Binary.create(LONG_OR, + tempLong1.copyRO(), tempLong1.copyRO(), tempLong2.copyRO())); + // Read unsigned source into tempLong2 + X86_DecodedOperand source; + source = modrm.getRM(translationHelper, lazy, sib, displacement, + operandSize, addressSize, (prefix2 != null) ? prefix2.getSegment() + : X86_Registers.DS); + OPT_RegisterOperand sourceOp = translationHelper.getTempInt(0); + source.readToRegister(translationHelper, lazy, sourceOp); + translationHelper.appendInstructionToCurrentBlock(Unary.create(INT_2LONG, + tempLong2, sourceOp.copyRO())); + translationHelper.appendInstructionToCurrentBlock(Binary.create(LONG_AND, + tempLong2.copyRO(), tempLong2.copyRO(), new OPT_LongConstantOperand(0xFFFFFFFF))); + // Check source isn't zero + OPT_RegisterOperand guard = translationHelper.getTempValidation(0); + translationHelper.appendInstructionToCurrentBlock( + ZeroCheck.create(LONG_ZERO_CHECK, guard, tempLong2.copyRO())); + + // Perform div + OPT_RegisterOperand quotient = translationHelper.getTempLong(2); + OPT_RegisterOperand remainder = translationHelper.getTempLong(3); + translationHelper.appendInstructionToCurrentBlock(GuardedBinary.create(LONG_DIV, + quotient, tempLong1.copyRO(), tempLong2.copyRO(), guard.copyRO())); + translationHelper.appendInstructionToCurrentBlock(GuardedBinary.create(LONG_REM, + remainder, tempLong1.copyRO(), tempLong2.copyRO(), guard.copyRO())); + + // TODO: if the value in EDX:EAX divided by SRC is > 0xFFFFFFFF then a + // divide error exception should be raised + + // Write values + translationHelper.appendInstructionToCurrentBlock(Unary.create(LONG_2INT, + eax.copyRO(), quotient.copyRO())); + translationHelper.appendInstructionToCurrentBlock(Unary.create(LONG_2INT, + edx.copyRO(), remainder.copyRO())); + return pc + length; + } + + /** + * Disassemble the opcode + * @param ps + * @param pc the address of the instruction being translated + * @param modrm the decoder for any modrm part of the instruction + * @param sib the sib decoder for any sib part of the instruction + * @param displacement any displacement to be added to the modrm + * @param immediateSize what size is the immediate value + * @param immedate if immediateSize > 0 then this is the immediate value + * @param length the length of the instruction + * @param prefix2 a group2 prefix decoder or null + * @param prefix3 a group3 prefix decoder or null + * @param prefix4 a group4 prefix decoder or null + * @param prefix5 a group5 prefix decoder or null + */ + protected String disassemble(ProcessSpace ps, int pc, + X86_ModRM_Decoder modrm, X86_SIB_Decoder sib, int displacement, + int immediateSize, int immediate, int length, + X86_Group2PrefixDecoder prefix2, X86_Group3PrefixDecoder prefix3, + X86_Group4PrefixDecoder prefix4, X86_Group5PrefixDecoder prefix5) { + int operandSize; + if (prefix3 == null) { + operandSize = this.operandSize; + } else if (this.operandSize == 32) { + operandSize = 16; + } else { + operandSize = 32; + } + int addressSize; + if (prefix4 == null) { + addressSize = _16BIT ? 16 : 32; + } else { + addressSize = _16BIT ? 32 : 16; + } + + String source; + source = modrm.disassembleRM(sib, displacement, operandSize, addressSize, + (prefix2 != null) ? prefix2.getSegment() : X86_Registers.DS); + return "div " + source; + } +} + +/** * The decoder for the PushA opcode */ class X86_PushA_OpcodeDecoder extends X86_OpcodeDecoder { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |