Sometimes we actually want to move the address of a variable into a register. Since addresses are 32 bits, we can only move addresses into the 32 bit registers.
For example, suppose that we wished to move the address of the variable myvar2 into the EAX register. We simply type
The EAX register is now a pointer to myvar2. It does not contain the contents of myvar2 (which may not even be a double word), but it contains the address of myvar2.top
Once we have moved an address into a 32 bit register, we are then free to move it into a double word variable for storage.
For example, suppose that EAX has been loaded with the address of some memory location storing a byte of data and suppose that we have a double word variable mypoint, say, that we want to store this address in. We simply write
Now here comes the tricky part. Let's suppose we want to load the contents of the memory location now pointed to by mypoint, into the CH register. Firstly we have to retrieve the address from storage:
Now EBX points to the location in question. Now to retrieve the byte of data at that location, we write
Here the square brackets do not denote the contents of EBX itself (for which we would just write EBX), but rather, they denote the contents of the location pointed to by EBX.
Although this usage of the square brackets may seem different to the earlier usage, it is in reality the same thing, since the thing inside the brackets is basically a pointer in both cases.