Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,255 of 4,675    |
|    Bartc to Veek M    |
|    Re: mov [a], rcx -vs- mov rax, [a]    |
|    21 Jan 18 18:28:32    |
      From: bc@nospicedham.freeuk.com              On 21/01/2018 08:05, Veek M wrote:       > Reading Ray Seyfarth - x86/Yasm assembly language. In it he uses the       following       >       > segment .data:       > a dq 175              I assume 'a' is a label, normally written as 'a:'.                     > segment .text       > global main       > main:       > mov rax, [a] ; to store the value of 'a' in rax              Wait, what do you mean its 'value'? 'a' is the address of a location       which contains 175 in a 64-bit format.              [a] is used to access the memory at address a. In this case, it will       read 175 at address a into register rax.              To load the address itself to rax, you'd use one of:               mov rax,a ; load address        lea rax,[a] ; load effective address, same as a, here              >       > But then he does:       >       > mov [a], rax; which ought to mean he's storing a value in the       value-of-a.              Here, the contents of rax are stored to memory at address 'a'.       Overwriting the 175.              >Therefore [a] is a pointer in this case? Is that so or is he storing in 'a'       somehow - slings and arrows of outrageous syntax?       >               > Thus leading to the conclusion [] acts as a de-reference operator.              In HLLs, 'dereferencing' is usually applied to pointer operations, not       normal variable accesses:               static int a; // 32-bit int        static int* p; // 64-bit pointer to 32-bit int               &a; // mov rax,a load address of variable        a; // mov eax,[a] load variable value (not called a dereference)        p; // mov rax,[p] load pointer value, not its target        *p; // mov rax,[p]; mov eax,[rax] deference pointer              --       bartc              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca