MOV Command
MOV {destination},{source}.
Assuming that you are using debug type in "A {enter}". You will see a bunch of number to the left. You can think of these as line numbers. Now type in "MOV AX,7A7A {enter}". Then type "MOV DX,AX" and so on until your program looks similar to the one below: (type "U 100" to see)
xxxx:0100 B8A77A MOV AX,7AA7
xxxx:0103 89C2 MOV DX,AX
xxxx:0105 B90000 MOV CX,0000
xxxx:0108 88D1 MOV CL,DL
xxxx:010A 890E0005 MOV [0500],CX
xxxx:010E 8B160005 MOV DX,[0500]
xxxx:0112 BB0200 MOV BX,0002
xxxx:0115 26A30005 MOV ES:[0500],AX
Press enter again until you see the "-" prompt again. You are ready to run your first program. Type "R {enter}" and note the values of the general purpose registers. Then type in "T {enter}". Debug will automatically display the registers after the execution of the instruction.
What is in the AX register? It should be 7AA7h. Now, "T" again. What is in the DX register? It should also be 7AA7h. Trace again using "T" and note that CX should be 0 if it was not already. Trace again and note what is in the CX register. It should be 00A7h. Now trace another step.
Purpose: It is moving the contents of CX into memory location 500h in the data segment (DS). Dump the memory by typing in "D 500". The first two two-digit numbers should be the same as in the CX register. But wait a minute you say. They are not the same. They are backwards. Instead of 00A7h, it is A700h. This is important. The CPU stores 16 bit numbers in memory backwards to allow for faster access. For 8 bit numbers, it is the same.
Now, continue tracing. This instruction is moving the memory contents of address 500h into the DX register. DX should be 00A7h, the same as CX regardless of how it looked in memory. The next trace should be nothing new. The next trace again moves the contents of a register into memory. But notice it is using the BX register as a displacement. That means it adds the contents of BX and 500h to get the address, which turns out to be 502h. But also not the "ES:" in front of the address. This additional statement tells the CPU to use the extra segment (ES) rather than the data segment (DS which is the default). Now dump address 502h by entering "D ES:502" and you should see A77Ah, which is backwards from 7AA7h.