0

What does the line : "d: db 'hey',0xa" represent. I know d is a symbol but what does it mean when I use it like that: "mov eax, d"? Do I put the value or the address into eax? What does the symbol represent when I use it?

Secondly, to write output we must fill the ecx register with the pointer to the value, normally like this : "mov ecx, [v1]". But why do I have to put the bracket? Can't I just mov the value of the address in ecx?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • In NASM `mov eax, d` puts the address of the `'hey', 0xa` string into `eax`. – ecm Aug 07 '21 at 11:35
  • 1
    You *can* just `mov ecx, v1`, if `v1` is a label on a `db`. If you have a pointer *stored in memory* (like C `static char *v1 = d;` instead of just `static char d[] = "hey\n";`), then yeah you have to load it (memory source, i.e. square brackets), not just mov-immediate of a constant address to a register. Without specifying what's at `v1`, the premise of your 2nd paragraph looks wrong. – Peter Cordes Aug 07 '21 at 11:41
  • Related: [How to load address of function or label into register](https://stackoverflow.com/q/57212012) for x86-64 – Peter Cordes Aug 07 '21 at 11:44

0 Answers0