NO

Author Topic: please help - don't understand this  (Read 5687 times)

Diddl

  • Guest
please help - don't understand this
« on: September 04, 2007, 04:36:20 PM »
I have visual C6 code and want to make it run on Pelles C. The problem is it compiles fine but isn't working on Pelles C. And I don't understand this assembler code, I have no idea how it works.

Could anyone explain how this works? Or write anything in pure C which does the same?



Code: [Select]
static _inline void clipit8 (float f, int32_t a)
{
   _asm
   {
      mov edi, a
      fld dword ptr f
      fadd dword ptr fakeadd
      fstp dword ptr fpuasm
      mov eax, fpuasm
      test eax, 0x007fff00
      jz short skipit
      shr eax, 16
      xor eax, -1
skipit: mov byte ptr [edi], al
   }
}

static _inline void clipit16 (float f, int32_t a)
{
   _asm
   {
      mov eax, a
      fld dword ptr f
      fist word ptr [eax]
      cmp word ptr [eax], 0x8000
      jne short skipit2
      fst dword ptr [fpuasm]
      cmp fpuasm, 0x80000000
      sbb word ptr [eax], 0
skipit2: fstp st
   }
}