I understand when for example [BX] is in between brackets it is referring to its memory contents. But at the same time I do not understand that.
CMP [BX], 12ADH
CMP [BX], 12ADH
This is actually an invalid instruction, as you haven't specified the size of the first operand. Assuming you intend a WORD (16-bit) comparison, like:
CMP WORD [BX], 12ADH
This will first fetch a 16-bit WORD from memory at the address specified in the BX register. Then, it will compare that value to the immediate value 12ADh
.
Note that CMP
does the same thing as SUB
, but without actually modifying any values. It only "pretends" to do the subtraction, and sets the FLAGS
accordingly.
MOV EBX, [BX]
This will fetch a 32-bit DWORD from memory at the address specified in the BX register. Then, it will store that value in the EBX register.
In an expression like WORD [BX]
, we can say that BX "points to" a 16-bit WORD in memory:
Memory Register File
...
_________ ________
100h | 1234h | /---- | 102h | BX
|_________| | |________|
102h | 5678h | <---/ ...
|_________|
104h | 9ABCh |
|_________|
106h | DEF0h |
|_________|
...