Ichimonji_bleach
Ichimonji_bleach

Reputation: 17

Label in Inline Assembly GCC

I'm using x86-64 architecture with AMD Processor and I'm also running Linux with Debian-distro. I want to use label directly in the inline assembly and also i want to use goto label in assembly code

Code Example :

#include <iostream>
int main() {
    int a = 5, b = 5;
    __asm__ __volatile__ (
        "cmp %1, %2\n\t"
        "je %l[match]\n\t"
        :
        : "r" (a), "r" (b)
        : 
        : match
    );
    std::cout << "Tidak cocok!\n";
    return 0;
match:
    std::cout << "Cocok!\n";
    return 0;
}

Compiling:

g++ asm.cpp -o p
 
asm.cpp: In function ‘int main()’:
asm.cpp:11:6: error: expected ‘)’ before ‘:’ token
   11 |     :
      |      ^
      |      )
   12 |     :
      |     ~ 

what's wrong with the code?

Upvotes: -1

Views: 41

Answers (0)

Related Questions