Skip to content

Intel asm instructions preceded by "lock" are only recognised in lower case #62326

Open
@ben-cohen-xs

Description

@ben-cohen-xs

Assembler instructions in Intel format are normally case insensitive in the Clang inline assembler. But if you use the lock prefix then the following instruction needs to be in lower case. If it is in upper case then you get the error "invalid instruction mnemonic", which is not what I would expect.

$ clang --version
clang version 14.0.5 (Fedora 14.0.5-2.fc36)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ cat test.c
int main()
{
    // Expected/Observed: The next line compiles successfully
    asm("lock inc eax;\n");

    // Expected: The next line compiles successfully
    // Observed: "error: invalid instruction mnemonic 'INC'"
    asm("lock INC eax;\n");
    return 0;
}

$ clang -o test ./test.c -masm=intel  
./test.c:8:9: error: invalid instruction mnemonic 'INC'
    asm("lock INC eax;\n");
        ^
<inline asm>:2:2: note: instantiated into assembly here
        lock INC eax;
        ^~~~
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions