flat assembler
Message board for the users of flat assembler.

Index > Main > Moving Certain Quadruplets between YMM registers

Author
Thread Post new topic Reply to topic
ml64



Joined: 17 Jul 2020
Posts: 6
ml64
After some computations, there are eight 32-bit Singles in YMM4:
YMM4[0]...YMM4[7]
Some of these values will be used as arguments for OpenGL functions.
How to perform such operations directly in YMM-registers without using Memory:
<move> YMM0[0],YMM4[4]
<move> YMM1[0],YMM4[5]
<move> YMM2[0],YMM4[6]


Last edited by ml64 on 17 Aug 2020, 15:17; edited 2 times in total
Post 17 Aug 2020, 12:02
View user's profile Send private message Send e-mail Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1514
Furs
For the first four DWORDS/floats (YMM4[0]...YMM4[3]) you can use vmovaps and vpsrldq:
Code:
vmovaps ymm0, ymm4     ; ymm0[0]
vpsrldq ymm1, ymm4, 4  ; ymm1[0]
vpsrldq ymm2, ymm4, 8  ; ymm2[0]
vpsrldq ymm3, ymm4, 12 ; ymm3[0]    
For the next four DWORDS/floats, you can use vextractf128:
Code:
vextractf128 xmm4, ymm0, 1  ; ymm4[0]
vextractf128 xmm5, ymm0, 1  ; ymm5[0]
vextractf128 xmm6, ymm0, 1  ; ymm6[0]
vextractf128 xmm7, ymm0, 1  ; ymm7[0]    
I don't know if it's the fastest but I think it's the shortest (one instruction for each).
Post 17 Aug 2020, 13:38
View user's profile Send private message Reply with quote
ml64



Joined: 17 Jul 2020
Posts: 6
ml64
Furs, thanks a bunch!
It looks like in 2020 there's no effective way to extract certain 32 bits from one YMM register to another.
Both vpsrldq and vextractf128 require cleaning the upper bits (e.g. with the vector AND instruction).
PEXTRD requires general-purpose register.
The simplest way is to store the whole 256 bits value to some variable in the RAM and to take dwords by address:
Code:
vmovups yword [P],ymm3
invoke glColor3f,  float dword [P.r], float dword [P.g], float dword [P.b]
invoke glVertex3f, float dword [P.x], float dword [P.y], float dword [P.z]    
Post 18 Aug 2020, 18:02
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.