I wrote a program which will add two numbers in assembly. When I do a system call for scanf(), the instruction looks like this:

mov rcx, num1

Note: I have defined num1 in the bss section as:

num1 resb 10

And, when I try to move this value to say rax the instruction looks like:

mov rax, [num1]

From what I have learned, anything inside square brackets must only be computed in case of rm32. So, more like going to memory location but not reading what's in the memory.

How is this bracket helping here ?

Why do we need the memory location when we can have the direct value?

And my next instruction is:

sub rax, '00'

rax contains an address of num1. Shouldn't we be doing math to the value num1 and not on the address ?

  • just because it's about assembler does not mean it's RE
    – Igor Skochinsky
    Jul 9, 2017 at 14:02
  • Agreed. But it's related. That's the reason I posted it here.
    – Atply
    Jul 9, 2017 at 14:20

1 Answer 1


First of all, you are using the Intel syntax for the x86/amd64 assembly. So, in this syntax the brackets ([.]) stands for a dereference of the address it contains.

If you know C programming, [var] (in assembly) is exactly similar to '*var'.

In fact, the only small difficulty you have to handle here is that the num1 that you defined is already an address (I am speaking now about the nasm syntax and NOT about the Intel asm syntax).

So, move rcx, num1 means that you copy the address of num1 to rcx.

And, move rax, [num1] means that you copy the content of num1 to rax.

You may refer to this SO question which might explain your problem.

Not the answer you're looking for? Browse other questions tagged or ask your own question.