What is the meaning of a dollar sign in front of a gnu assembly label?
For example, what is the difference between mov msg, %si
and mov $msg, %si
(For more context, I'm playing around with the x86 Bare Metal Examples: https://github.com/cirosantilli/x86-bare-metal-examples/blob/master/bios_hello_world.S)
#include "common.h"
BEGIN
mov $msg, %si
mov $0x0e, %ah
loop:
lodsb
or %al, %al
jz halt
int $0x10
jmp loop
halt:
hlt
msg:
.asciz "hello world"
(What do the dollar ($) and percentage (%) signs represent in assembly intel x86? discusses the general use of % before registers and $ before constants; but, I don't think it lays out the use of $ with labels nearly as clearly as the answer below )
You use $(dollar) sign when addressing a constant, e.g.:
movl $1, %eax
(put 1
to %eax
register)
or when handling an address of some variable, e.g.: movl $var, %eax
(this means take an address of var
label and put it into %eax
register).
If you don't use dollar sign that would mean "take the value from var
label and put it to register".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With