Skip to content

'c' and 'v' do not work as asm clobber or output registers #329

Closed
@rweather

Description

Specifying "c" or "v" as clobber registers give an error, rather than being supported as described here.

int main(void)
{
    unsigned char a = 0x86;
    asm (
        "rol"
        : "+a"(a)
        :: "c"
    );
    asm (
        "bit llvm-mos/llvm-mos-sdk#27"
        : "+a"(a)
        :: "v"
    );
    return 0;
}

Result:

$ mos-common-clang asm-flags.c 
asm-flags.c:7:12: error: unknown register name 'c' in asm
        :: "c"
           ^
asm-flags.c:12:12: error: unknown register name 'v' in asm
        :: "v"
           ^
2 errors generated.

Attempting to use "c" (or "v") as an output register compiles OK, but causes a link-time crash and stack trace.

int main(void)
{
    unsigned char a = 0x86;
    unsigned char c;
    asm (
        "rol"
        : "+a"(a), "=c"(c)
        ::
    );
    return 0;
}

Result:

LLVM ERROR: unable to translate instruction: call (in function: main)

crash.txt

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions