assemblymakefilex86x86-64xed

How can I compile a set of ASM instructions in X86 Encoder Decoder (XED) syntax


I need to generate random ASM instructions. I found a really helpful XML file from UOPS which makes the random instruction generator program really simple. However, the XML file provides the instructions in Intel's X86 Encoder Decoder (XED) syntax, and I wanted to know if there is a way to compile them to an executable as you would with a NASM or MASM program.

The list of instructions would look something like this:

DEC R8W
LOCK ADC byte ptr [0xB8], 0x82
IN AX, DX
BTR qword ptr [RBX], 0xF7
IN EAX, DX
ADD RAX, 0x25C9FB2C
LOCK BTC qword ptr [RBP], 0xA5
CMOVBE ESI, R10D
{load} MOV CH, DL

I'm using Ubuntu 22.04


Solution

  • The instructions generated from the XML file are intended to be used with the Gnu assembler (in Intel syntax mode).

    You have to add the line .intel_syntax noprefix to the beginning of your file:

    .intel_syntax noprefix
    
    DEC R8W
    LOCK ADC byte ptr [0xB8], 0x82
    IN AX, DX
    BTR qword ptr [RBX], 0xF7
    IN EAX, DX
    ADD RAX, 0x25C9FB2C
    LOCK BTC qword ptr [RBP], 0xA5
    CMOVBE ESI, R10D
    {load} MOV CH, DL
    

    Then, you can generate an executable by running as <filename>.