Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22087

What's wrong with using data from C++ in asm with compiling by gcc? [duplicate]

$
0
0

I've got code like that:

int main()
{
    char input_string[MAX_LENGTH];
    char output_string[MAX_LENGTH];

    cin.getline(input_string, 80, '\n');

    asm
    (
        "lea eax, input_string\n""mov esi, eax\n""lea eax, output_string\n""mov edi, eax\n"

        // SOME CODE

And I get errors:

/usr/bin/ld: /tmp/ccuMmjjG.o: in function `main':
lr4_comments.cpp:(.text+0x110): undefined reference to `input_string'
/usr/bin/ld: lr4_comments.cpp:(.text+0x118): undefined reference to `output_string'
collect2: error: ld returned 1 exit status

I compile with:

g++ -masm=intel -m32 -o main main.cpp

What's the way to do it right in Intel syntax? P.S. adding '.intel_syntax;' do nothing, only adds extra errors.


Viewing all articles
Browse latest Browse all 22087

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>