Pelles C forum

Assembly language => Assembly discussions => Topic started by: Vortex on March 16, 2026, 08:45:29 PM

Title: Verifying the support of the instruction movbe
Post by: Vortex on March 16, 2026, 08:45:29 PM
Hello,

To check if your processor supports the instruction movbe :

include     movbeCheck.inc

.data

m1          db 'The processor does not support the instruction movbe.',0
m2          db 'The processor supports the instruction movbe.',0
StrTable    dd OFFSET m1,OFFSET m2

.code

start:

    call    main
    invoke  ExitProcess,0

main PROC

    xor     eax,eax
    push    eax
   
    mov     eax,1
    cpuid

    bt      ecx,22
    pop     eax
    adc     eax,0

    mov     edx,OFFSET StrTable
    lea     ecx,[edx+4*eax]

    invoke  printf,DWORD PTR [ecx]
    ret   

main ENDP

END start
Title: Re: Verifying the support of the instruction movbe
Post by: Vortex on March 16, 2026, 09:27:38 PM
Here is the 64-bit version :

include     movbeCheck.inc

.data

m1          db 'The processor does not support the instruction movbe.',0
m2          db 'The processor supports the instruction movbe.',0
StrTable    dq OFFSET m1,OFFSET m2

.code

start:

    sub     rsp,8+4*8
    call    main
    invoke  ExitProcess,0

main PROC PARMAREA=4*SIZEOF QWORD

LOCAL _rax:QWORD

    xor     rax,rax
    mov     _rax,rax
   
    mov     rax,1
    cpuid

    bt      rcx,22
    mov     rax,_rax
    adc     rax,0

    mov     rdx,OFFSET StrTable
    lea     rcx,[rdx+8*rax]

    invoke  printf,QWORD PTR [rcx]
    ret   

main ENDP

END start