sábado, 31 de outubro de 2009

Floating point comparison

float left, right;
unsigned char res = 0;
__asm push eax;
__asm fld [right];
__asm fld [left];
__asm fcompp;
__asm fnstsw ax;
__asm mov [res], ah;
__asm pop eax



left | right | ah | op
------+-------+------+---------------
-1.0 | 0.0 | 0x01 | left < right
0.0 | 0.0 | 0x40 | left == right
1.0 | 0.0 | 0x00 | left > right