Indeed, your thought is correct.That is, bl will contain 5 and cl the memory address of buffer(in fact the label buffer is a memory address itself).
Now, let me explain the differences between the operations you mentioned:
moving an immediate into a register can be done using
mov reg,imm
.What may be confusing is that labels e.g buffer are immediate values themselves that contain an address.You cannot really move a register into an immediate, since immediate values are constants, like
2
orFF1Ah
.What you can do is move a register to the place where the constant points to.You can do it likemov [const], reg
.You can also use indirect addressing like
mov reg2,[reg1]
provided reg1 points to a valid location, and it will transfer the value pointed by reg1 to reg2.
So, mov cl, buffer
will move the address of buffer to cl(which may or may not give the correct address, since cl is only one byte long) , whereas mov cl, [buffer]
will get the actual value.
Summary
- When you use [a], then you refer to the value at the place where a points to.For example, if a is
F5B1
, then [a] refers to the address F5B1 in RAM. - Labels are addresses,i.e values like
F5B1
. - Values stored in registers do not have to be referenced to as [reg] because registers do not have addresses.In fact, registers can be thought of as immediate values.