0

What did i did wrong?

**#include <stdio.h>
#include <stdlib.h>
int x,y,vysled=0;
int main()
{
    asm(".intel_syntax noprefix \n"
       "mov eax,_x              \n"
       "add eax,_y              \n"
       "mov _vysled,eax         \n"
       ".att_syntax             \n");
    printf("%d + %d = %d",x,y,vysled);
    return 0;
}**

building log prints Undefined reference to _x,_y.

Peter Cordes
  • 245,674
  • 35
  • 423
  • 606
  • What compiler are you programming for? This looks like you attempt to use MSVC-style inline assembly with gcc's syntax which won't work. – fuz Mar 10 '21 at 12:59
  • 1
    @fuz: It's GNU C Basic asm, not MSVC. Still very bad, but the variables are global so this actually *could* compile with the right asm symbol names to match the target platform. But it would be unsafe other than in a debug build. (clobbering EAX, and asm reading and writing memory without a "memory" clobber or listing them as input or output operands). Dávid - see https://stackoverflow.com/tags/inline-assembly/info – Peter Cordes Mar 10 '21 at 14:25

0 Answers0