flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [fasmg] Problem with VPMASKMOVQ AVX2 instruction

Author
Thread Post new topic Reply to topic
bdlepla



Joined: 05 Sep 2023
Posts: 4
bdlepla 05 Sep 2023, 02:42
using flat assembler version g.k4v8

Snippet I'm assembling:
Code:
        vpmaskmovq      ymm1,ymm0,[rsi]                 
        vpmaskmovq      [rdi],ymm0,ymm1    


when I use the following to disassemble my program (on Linux):
Code:
objdump -d test > test.s    


This is what is produced for my snippet:
Code:
        401424: c4 e2 fd 8c 0e          vpmaskmovq (%rsi),%ymm0,%ymm1
        401429: c4 e2 f9 8e 0f          vpmaskmovq %xmm1,%xmm0,(%rdi)  ; <-- this should be using ymm0 and ymm1, not xmm0 and xmm1    


The issue is that the second call to vpmaskmovq to move from ymm1 with mask ymm0 to memory, is erroneously using xmm1 and xmm0 instead.

Any ideas? Thanks in advance.
Post 05 Sep 2023, 02:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20422
Location: In your JS exploiting you and your system
revolution 05 Sep 2023, 04:20
The encoding should be FD
Code:
~ ndisasm -b 64 bdlepla.bin
00000000  C4E2FD8C0E        vpmaskmovq ymm1,ymm0,yword [rsi]
00000005  C4E2F98E0F        vpmaskmovq oword [rdi],xmm0,xmm1
0000000A  C4E2FD8E0F        vpmaskmovq yword [rdi],ymm0,ymm1    
Post 05 Sep 2023, 04:20
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20422
Location: In your JS exploiting you and your system
revolution 05 Sep 2023, 04:21
fasm assembles it correctly. fasmg is incorrect.
Post 05 Sep 2023, 04:21
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 05 Sep 2023, 06:17
It's a mistake in my implementation of AVX2 for fasmg. The same issue is also present in x86-2 encoder (and therefore fasm 2). I'm correcting it in all places.
Post 05 Sep 2023, 06:17
View user's profile Send private message Visit poster's website Reply with quote
bdlepla



Joined: 05 Sep 2023
Posts: 4
bdlepla 05 Sep 2023, 12:36
Thank you both. I applied the changes locally and all is well.
Post 05 Sep 2023, 12:36
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.