Consider
int main(){ char *nameptr = "ale"; char namearr[] = "lea"; double dval = 0.5; } This assembles to (https://godbolt.org/z/rW16sc6hz):
.LC0: .string "ale" main: pushq %rbp movq %rsp, %rbp movq $.LC0, -8(%rbp) movl $6382956, -20(%rbp) movsd .LC1(%rip), %xmm0 movsd %xmm0, -16(%rbp) movl $0, %eax popq %rbp ret .LC1: .long 0 .long 1071644672 Given that "ale" and "lea" are lvalues, what explains the difference in treatment of how they are encoded? "lea" gets encoded as decimal 6382956, which when converted to hex becomes the ascii values of l, e and a. "ale" is placed in a se...
Consider
int main(){ char *nameptr = "ale"; char namearr[] = "lea"; double dval = 0.5; } This assembles to (https://godbolt.org/z/rW16sc6hz):
.LC0: .string "ale" main: pushq %rbp movq %rsp, %rbp movq $.LC0, -8(%rbp) movl $6382956, -20(%rbp) movsd .LC1(%rip), %xmm0 movsd %xmm0, -16(%rbp) movl $0, %eax popq %rbp ret .LC1: .long 0 .long 1071644672 Given that "ale" and "lea" are lvalues, what explains the difference in treatment of how they are encoded? "lea" gets encoded as decimal 6382956, which when converted to hex becomes the ascii values of l, e and a. "ale" is placed in a separate memory location, labelled .LC0. Is this because "ale" is nonmodifiable, while "lea" is in the context of being assigned to a pointer whereas the latter is assigned to an array?
Despite not being an lvalue, why does 0.5 get encoded analogous to "ale"? i.e. why is there another memory location labelled .LC1 used for double encoding?
Furthermore, what explains .LC0 vs .LC1(%rip)? Is it because the label .LC1 occurs later in the code therefore one needs to reference it via %rip whereas .LC0 is earlier in the code so there is no need for %rip?