News:

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

Sorry if this is a common question

Started by savage, June 13, 2006, 03:08:37 PM

Previous topic - Next topic

asmfan

I think the Ossa's code should contain mask = 80000000h to work correct... on sign bit
Russia is a weird place

Ossa

For floats, definately just do the and.

For integers, the code you just posted won't work as it is for floating point values (a quick glance says that the code will work for floats, but it will be much slower than the and you posted about right at the start).

Quote from: asmfan on June 15, 2006, 04:22:41 PM
I think the Ossa's code should contain mask = 80000000h to work correct... on sign bit

Exactly right asmfan:

mask1 OWORD  80000000800000008000000080000000h

movaps   xmm2, xmm1
pand     xmm2, mask1
pcmpeqd  xmm2, mask1 ; xmm1 has all 1s for any dword that is negative

pxor     xmm1, xmm2
psubd    xmm1, xmm2


Thanks for spotting that.

[edit] Just edited it to get it assemble under MASM... also used MOVAPS instead of MOVDQA (SSE instead of SSE2) [/edit]

Ossa
Website (very old): ossa.the-wot.co.uk

savage

I just thought of this method for eax registers:


bt eax, 31
adc eax, 0





mov ecx, 45 ; << number to be absoluted

xor eax, eax
bt ecx, 31
adc eax, 0
adc ecx, 0
neg eax
sbb ecx,0
xor ecx, eax


Well at least that works, it's obviously not optimised
just a weird idea