flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] movbe (0x0F 0x38 0xF[01]) instruction?

Author
Thread Post new topic Reply to topic
sylware



Joined: 23 Oct 2020
Posts: 462
Location: Marseille/France
sylware 09 Aug 2021, 12:57
It seems this instruction is missing, or it is me missing something.
Post 09 Aug 2021, 12:57
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 09 Aug 2021, 14:31
MOVBE is one of the single-instruction extensions that have dedicated CPUID bits, in fasmg's headers set it should therefore have its own file (ext/movbe.inc). I've been slowly adding most of the Intel extensions (I did not even begin with AMD-specific stuff), but it's never been complete.
Post 09 Aug 2021, 14:31
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 462
Location: Marseille/France
sylware 09 Aug 2021, 15:12
after reading the suggested thread (which the forum search engine did not return to me, sorry)... well it does not make movbe shine.
Now dunno if I should use it.
Post 09 Aug 2021, 15:12
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 09 Aug 2021, 15:39
Code:
; CPUID Fn0000_0001_ECX[MOVBE] = 1
calminstruction movbe? dest*,src*
        asmcmd  =x86.=parse_operand =@dest,dest
        asmcmd  =x86.=parse_operand =@src,src

        local   size

        check   @dest.size <> 0 & @src.size <> 0 & @dest.size <> @src.size
        jyes    operand_sizes_do_not_match

        compute size, @dest.size or @src.size
        check   size > 1
        jno     invalid_operand_size

    main:
        check   @dest.type = 'reg' & @src.type = 'mem'
        jyes    movbe_reg_mem
        check   @dest.type = 'mem' & @src.type = 'reg'
        jyes    movbe_mem_reg

    invalid_combination_of_operands:
        asmcmd  =err 'invalid combination of operands'
        exit

    movbe_reg_mem:
        asmcmd  =x86.=select_operand_prefix =@dest,size
        asmcmd  =x86.=store_instruction <0Fh,38h,0F0h>,=@dest,=@src.=rm
        exit

    movbe_mem_reg:
        asmcmd  =x86.=select_operand_prefix =@src,size
        asmcmd  =x86.=store_instruction <0Fh,38h,0F1h>,=@src,=@dest.=rm
        exit

    invalid_operand_size:
        asmcmd  =err 'invalid operand size'
        compute size, 0
        jump    main

    operand_sizes_do_not_match:
        asmcmd  =err 'operand sizes do not match'
        compute size, 0
        jump    main

end calminstruction    
Just copy-paste (no testing).
This instruction was introduced with Intel Atom and later migrated (movbe'd Very Happy) to higher end processors.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 09 Aug 2021, 15:39
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 462
Location: Marseille/France
sylware 09 Aug 2021, 18:47
It does not work. As far I understand, it seems related to modrm/sib bytes computation.
Well, I have to dive into this because I got hit by the missing "pdep" instruction too.
Post 09 Aug 2021, 18:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 09 Aug 2021, 19:07
sylware wrote:
Well, I have to dive into this because I got hit by the missing "pdep" instruction too.
PDEP is part of the BMI2 extension, you can get it by including "ext/bmi2.inc".
Post 09 Aug 2021, 19:07
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 09 Aug 2021, 19:11
Oh, I got the dest<>src mixed up in the output. Maybe there is something else too?
Code:
    movbe_reg_mem:
        asmcmd  =x86.=select_operand_prefix =@src,size
        asmcmd  =x86.=store_instruction <0Fh,38h,0F0h>,=@src,=@dest.=rm
        exit

    movbe_mem_reg:
        asmcmd  =x86.=select_operand_prefix =@dest,size
        asmcmd  =x86.=store_instruction <0Fh,38h,0F1h>,=@dest,=@src.=rm
        exit    
... fixes it perhaps.

Some more instructions, SSE4a, etc...
https://board.flatassembler.net/topic.php?t=21823

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 09 Aug 2021, 19:11
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 462
Location: Marseille/France
sylware 09 Aug 2021, 21:09
Tomasz Grysztar wrote:
PDEP is part of the BMI2 extension

ok... my egrep -i was a failure then or I don't know what I did... jez, really unlucky with text search lately.

bitRAKE wrote:
I got the dest<>src mixed up
working now, I get the right modrm byte, thx!
Post 09 Aug 2021, 21:09
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.