assembly - c++ __asm code (How to transfer double to ax) -


this may sound stupid or lazyness. know ax register 16bit , double 64bit. how transfer double ax using __asm? question more of, how break them 4(16 bits) or maybe access 3(16 bits) go ax of double using asm?

part2 how transfer 16bit (bitwise) i?

int main(void) {   double i= 0;    __asm   {     mov ax, i;     //some calucation     mov i, ax;   }   std::cout << << std::endl;   return 0; } 

lastly, movsx, , movsz

if want convert value of double 16 bit int:-

double d=3.1415; __asm {   push ax   fld [d]   fistp word ptr [esp]   pop ax ; ax = 3 } 

and value 32 bit int:-

double d=3.1415; __asm {   push eax   fld [d]   fistp dword ptr [esp]   pop eax ; eax = 3 } 

if want bit wise representation of least significant bits of floating point value:-

double d=3.1415; __asm {   lea edx,[d]   mov ax,[edx] ; lowest 16 bits   mov eax,[edx] ; lowest 32 bits   mov eax,[edx+4] ; bits 32-63   ; etc } 

but not useful, , tricky deal with, unless you're doing infamous inv-sqrt trick (which doesn't gain speed on modern processors).

note: written using devstudio 2005.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -