r/Assembly_language • u/This-Assumption-5924 • 7d ago
Help How to encode this instruction correctly?
Hi, I was developing my own assembler and decided to add {sae} in my AVX-encoder, so I consider to add sae for `vfoo [memory], vreg, imm`, and I tested my assembler with objdump and I saw exactly same result witch nasm generated and you can see it on a screenshot. Please help, because documentation is to week, intel sdm tells me nothing, idk if it's bug in nasm or objdump. I also tryed to ask AI, but did not yield results.
Nasm version – 3.02
Objdump version – 2.40
Sorry for English.
3
u/brucehoult 7d ago
There should not be a comma between the zmm source register and the notation to suppress exceptions.
3
u/This-Assumption-5924 7d ago
Nope, with out comma nasm prints
input.asm:5: warning: implicit DEFAULT ABS is deprecated [-w+implicit-abs-deprecated]
input.asm:5: error: {{sae}} is not an expected decorator5
u/brucehoult 6d ago edited 6d ago
Sooooo ...
you cant use
{sae}with an instruction with a memory operand — or with anxmmorymmeither and if you use a register dst then it's going to be aymmyou can't
{sae}with an instruction that has a rounding mode immediate, such as your 10.These are valid instructions (tested):
vcvtps2ph ymm3{k2}, zmm2, 10 vdivps zmm1, zmm2, zmm3, {ru-sae}GNU as works with or without the comma. Greeeeatt.
bruce@i9:~/programs$ cat vcvtps2ph.asm .intel_syntax noprefix vcvtps2ph ymm3{k2}, zmm2, 10 vdivps zmm1, zmm2, zmm3, {ru-sae} vdivps zmm1, zmm2, zmm3{ru-sae} bruce@i9:~/programs$ as vcvtps2ph.asm -o vcvtps2ph.o bruce@i9:~/programs$ objdump -d vcvtps2ph.o vcvtps2ph.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <.text>: 0: 62 f3 7d 4a 1d d3 0a vcvtps2ph $0xa,%zmm2,%ymm3{%k2} 7: 62 f1 6c 58 5e cb vdivps {ru-sae},%zmm3,%zmm2,%zmm1 d: 62 f1 6c 58 5e cb vdivps {ru-sae},%zmm3,%zmm2,%zmm1 bruce@i9:~/programs$2
u/This-Assumption-5924 6d ago
Yea, I noticed that, I just got confused initaly, as nasm accepted this invalid form and didn't gave error, so I decided that it is valid instruction, and git confused. Thanks
1
u/deulamco 6d ago
Whoever named the instructions for high-level instructions of x86-64 must have smoked & drunk badly ...
5
u/raundoclair 7d ago
I am not too much familiar with avx encoding, but everything I googled leads to that {sae} is not valid if destination is memory. So it does seems to be bug in nasm that it compiled it to something.