Use of constraints when mapping C variables to ASM symbolic names?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to compile some C code with inline assembly. I already have
the ASM code, so I don't need anything generated. Effectively, all I
need to do is map a C variable to an ASM symbolic name so I can use
the variables directly in MASM-like fashion.

I'd like to use a constraint that says, "this is a C variable", but
there does not seem to be one. I'd also like to use a "no constraint"
specifier because all I am doing is mapping C names to ASM symbolic
names, but there does not seem to be one. An empty constraint string
on outputs produces an error.

I think the next closet constraint is the "X" one, but its causing
trouble. For example, with "X", the machinery is doing nonsensical
things like (from --save-temps):

  /APP
   # 155 "cpu.cpp" 1
    .att_syntax
    .att_syntax
     pushl %ebx
     movl $-2147483647, %eax
     movl $0, %ecx
     cpuid
     movl %eax, %xmm0
     movl %ebx, %xmm1
     movl %ecx, %ebp
     movl %edx, %xmm2
     popl %ebx

How do I (1) map C variables to ASM symbolic names and (2) tell the
machinery to *not* generate any code because I've already provided it.

**********

Here's the MASM-like code I am trying to use:

        "\t pushl %%ebx \n"

        "\t movl %[__FUNC], %%eax \n"
        "\t movl %[__SUBFUNC], %%ecx \n"

        "\t cpuid \n"

        "\t movl %%eax, %[__EAX] \n"
        "\t movl %%ebx, %[__EBX] \n"
        "\t movl %%ecx, %[__ECX] \n"
        "\t movl %%edx, %[__EDX] \n"

        "\t popl %%ebx \n"

__FUNC, __SUBFUNC, etc shadow a 32-bit C variable. That's all they do.

**********

Here's the stream of errors its producing:

g++: warning: -pipe ignored because -save-temps specified
cpu.s: Assembler messages:
cpu.s:129: Error: operand type mismatch for `mov'
cpu.s:130: Error: operand type mismatch for `mov'
cpu.s:131: Error: operand type mismatch for `mov'
cpu.s:153: Error: operand type mismatch for `mov'
cpu.s:154: Error: operand type mismatch for `mov'
cpu.s:156: Error: operand type mismatch for `mov'
cpu.s:342: Error: operand type mismatch for `mov'
cpu.s:473: Error: operand type mismatch for `mov'
cpu.s:474: Error: operand type mismatch for `mov'
cpu.s:475: Error: operand type mismatch for `mov'
cpu.s:497: Error: operand type mismatch for `mov'
cpu.s:498: Error: operand type mismatch for `mov'
cpu.s:500: Error: operand type mismatch for `mov'
cpu.s:684: Error: operand type mismatch for `mov'



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux