flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg][x86] Missing/incomplete instructions macros

Author
Thread Post new topic Reply to topic
GamoveR



Joined: 19 May 2019
Posts: 2
GamoveR 01 Jul 2019, 12:16
I generaly use fasmg for write high performance functions. So sometimes I have to use "seldom used instructions". I've noticed that instruction "prefetchw" have no macro in "fasmg package". I wrote my own based on macros for "prefetcht* instructions:
Code:
macro prefetchw? src*
        x86.parse_operand @src,src
        if @src.type = 'mem'
                if @src.size and not 1
                        err 'invalid operand size'
                end if
                x86.store_instruction <0Fh,0Dh>,@src,1
        else
                err 'invalid operand'
        end if
end macro
    



Also I found that "movnti" macro works only with 32 bits registers. I try to improve this macro to use also 64 bits registers:
Code:
macro movnti? dest*,src*
        x86.parse_operand @dest,dest
        x86.parse_operand @src,src
        local size
        if @dest.size = 0 & @src.size = 0
                err 'operand size not specified'
        else if @dest.size <> 0 & @src.size <> 0 & @dest.size <> @src.size
                err 'operand sizes do not match'
        else
                size = @dest.size or @src.size
        end if

        if @dest.type = 'mem' & @src.type = 'reg'
                if size <> 4 & size <> 8
                        err 'invalid operand size'
                end if
                x86.select_operand_prefix @dest,size
                x86.store_instruction <0Fh,0C3h>,@dest,@src.rm
        else
                err 'invalid combination of operands'
        end if
end macro
    
Post 01 Jul 2019, 12:16
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 01 Jul 2019, 18:54
Thank you! This is an ongoing process that I have trouble finishing, but I hoped that the macros should be manageable enough for people to tweak them whenever a need arises, and you are proving that my trust was not misplaced. Wink

If I remember correctly, PREFETCHW was originally introduced by AMD 3DNow! and this extension is not in my macro sets because I wanted to go purely for Intel-branded extensions at first. On the other hand, nowadays Intel has it too and there should probably be a separate include file for just this single instruction.

Ideally, I should probably just go through the list of all CPUID feature flags and make sure that there is an include file for each one of them...
Post 01 Jul 2019, 18:54
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 438
Location: Marseille/France
sylware 20 Sep 2021, 16:35
Ran into the missing "prefetchw" instruction (fasmg).

It seems "prefetchw" is now a part of the CPUID 0x80000001 ECX[08].
On intel since broadwell.
Post 20 Sep 2021, 16:35
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.