chyyuu / distorm

Automatically exported from code.google.com/p/distorm
GNU General Public License v3.0
0 stars 0 forks source link

FNSTCW operand have a 0 bit access size instead of 16 #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

if you compile this code:
  unsigned int index;
  double value = 0.0;
  unsigned int uint_value = static_cast<unsigned int>(value);
  if (value == static_cast<double>(uint_value)) {
    index = uint_value;
    return true;
  }

with VS2010, it produce this assembly code:

  ...
  fld     qword ptr [L00420230]
  fstp    qword ptr [ebp-24h]
  fld     qword ptr [ebp-24h]
  fnstcw  word  ptr [ebp-00000126h]
  ...

if you run distorm on it, the inst.ops[0].size for the fnstcw instruction is 0, 
instead of 16... (I get the same bug with others instructions like fldcw).

On Win7 64 bits.
__DISTORMV__ 0x030200
C version of distorm.

Original issue reported on code.google.com by sebmarch...@google.com on 23 Nov 2012 at 7:51

GoogleCodeExporter commented 9 years ago
I've just seen that there's a new version of distorm available (0x030300). I'm 
checking if this bug is still here.

Original comment by sebmarch...@google.com on 23 Nov 2012 at 7:58

GoogleCodeExporter commented 9 years ago
Updating to the latest revision don't fix the bug :(

Original comment by sebmarch...@google.com on 23 Nov 2012 at 8:48

GoogleCodeExporter commented 9 years ago
Seems like changing the operand type to MEM16 would do in this case.
I will fix it, please let me know if you experience the same problem in other 
instructions.
I remember that I didn't set the size precisely for many FPU instructions, 
because back at the time it didn't look really useful...

Original comment by distorm@gmail.com on 24 Nov 2012 at 11:11

GoogleCodeExporter commented 9 years ago

Original comment by distorm@gmail.com on 20 Dec 2012 at 5:12

GoogleCodeExporter commented 9 years ago
Hum, this doesn't seem to be fixed in r230... Here is 2 input buffer that still 
ends up with inst.ops[0].size == 0. The opcode is well decoded. 
// fnstcw m16
const uint8 kFnstcw[] = { 0xD9, 0x7D, 0xEA };
// fldcw m16
const uint8 kFldcw[] = { 0xD9, 0x6D, 0xE4 };

Original comment by sebmarch...@google.com on 20 Dec 2012 at 10:56

GoogleCodeExporter commented 9 years ago
Ahh this is awkward, fixed. :)

Original comment by distorm@gmail.com on 13 Dec 2014 at 4:21