If x always is 2 i.e 2^3 you can do it like this
Result in eaxCode:mov eax,2 shl eax,2
If you use mul you do it like this (5^3)
Result in eaxCode:mov eax,5 mov ecx,2 jmp @F back: mov edx,5 mul edx dec ecx @@: cmp ecx,0 ja back
If you use co-processor you do i like this (5^3)
Code:finit ;Initialize the co-processor mov eax,0 ;Load push eax ;3 mov eax,3 ;to stack push eax ;as a qword fild qword ptr [esp] ;Load 3 from stack to 80-bit register st(0)=3 add esp,8 ;Restore stack mov eax,0 ;Load push eax ;5 mov eax,5 ;to stack push eax ;as a qword fild qword ptr [esp] ;Load 5 from stack to next register st(0)=5, st(1)=3 add esp,8 ;Restore stack fyl2x ;st(0)=st(1)*log2(st(0)) => st(0)=5*log2(3) fst st(1) ;Store st(1)=st(0)=5*log2(3) frndint ;Round ST(0) to an integer fsub st(1),st(0) ;Subtract st(0) from st(1) => st(0)=integer and st(1)=fraction fxch st(1) ;Exchange st(0) and st(1) f2xm1 ;computes the exponential value of 2 to the power of the value of ST(0) and subtracts 1 fld1 ;Load value 1 to st(0). st(0)=1, st(1)=2^st(0), st(2)=integer fadd ;st(0)=2^st(0), st(1)=integer fscale ;Scale ST(0) by ST(1) fwait ;Wait while co-processor is busy fstp fResult ;Store in fResult(qword) and pop ST(0)




Reply With Quote