News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

making a constant in a register

Started by asmfan, March 06, 2006, 10:09:58 PM

Previous topic - Next topic

asmfan

hello,
here i would like you to post the different effective ways of setting registers ( ALU, FPU, MMX, XMM or others:) to a constant. as an example
xor R, R  ; set R to a zero (R=0)
or R, -1  ; set all bits in R
pcmpeq MMX, MMX  ; set all bits in mmx register
and all that kind.
everyone experienced is welcomed
Russia is a weird place

zooba

I have found that in some cases,  mov R, -1 is faster than or R, -1. I believe this is since or requires that the the value or R be known which may cause stalls/etc.

Xor doesn't suffer from this because it has been special cased for setting a register to zero (since the original Pentium I think it was...)

dsouza123

For the FPU from the Floating Point Help file

FLD1      Push 1.0 onto stack
FLDZ      Push 0.0 onto stack
FLDPI      Push pi onto stack
FLDL2E   Push base-2 log of e onto stack
FLDL2T   Push base-2 log of 10 onto stack
FLDLG2   Push base-10 log of 2 onto stack
FLDLN2   Push natural log of 2 onto stack