Dollar sign value in gnu assembly labels

What is the meaning of the dollar sign in front of the gnu assembly label?

For example, what is the difference between mov msg, %si

andmov $msg, %si

(For more context, I'm playing around with 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 signs ($) and percent (%) mean in intel x86 assembly? Discusses the general use of% before registers and $ before constants; but, I don't think this implies the use of tagged $ is almost as clear as the answer below )

+3


source to share


1 answer


You use the $ (dollar) sign when referring to a constant, for example: movl $1, %eax

(put 1

in a %eax

register) or when handling the address of some variable, for example: movl $var, %eax

(this means the address is a var

label and put in a register %eax

). Unless you use a dollar sign , which means "take the value from the var

label and put it in register" .. p>



+2


source







All Articles