What does the dollar sign mean in __asm?

I tried to use this game, and I could not find anything informative enough for my understanding.

int i; char msg1[] = "odd"; char msg2[] = "even"; char *ptr; __asm__(" \ movl i, %eax\n\ andl $1, %eax\n\ jz zero\n\ movl $msg1, %eax\n\ jmp done\n\ zero:\n\ movl $msg2, %eax\n\ done:\n\ movl %eax, ptr\n\ "); 

Why do we need $ , and the other (for example, i) does not have the $ sign?

+4
source share
3 answers

$1 is permanent

  `andl $1, %eax` this means do AND of 1 and EAX register. 

$ prefix infront of contants and immediate evaluation. msg1 and msg1 are the addresses of two arrays. Therefore, they have the $ prefix.

i is the variable c. Accessed through memory access (indirect link).

Check out the link .

+2
source

Constants must be prefixed with "$" .

 movl $msg1, %eax\n\ 

The dollar sign meant constant, and the same is true for $msg1 . The constant here is the msg1 address.

+1
source

$ here is the same as in C / C ++, means address

0
source

Source: https://habr.com/ru/post/1344423/


All Articles