In assembly language, MOV instructions are data transfer instructions, and are also the most basic programming instructions, used to transfer a data from the source address to the destination address (data transfer between registers is essentially the same). Its characteristic is that it does not destroy the content of the source address unit.
For example:
MOV AX, 2000H; transfer 16-bit data 2000H to AX register
MOV AL, 20H; transfer 8-bit data 20H to the AL register
MOV AX, BX; transfer 16-bit data from the BX register to the AX register
MOV AL, [2000H]; transfer the contents of the 2000H unit to the AL register
What should be noted is:
(1) Data cannot be transmitted directly between two memory units, that is, the MOV instruction only allows one operand in memory. MOV [SI], [2000H]; this is wrong
(2) The immediate number in the MOV instruction cannot be directly transmitted to the segment registers (CS, DS, SS, ES) and IP; the segment registers cannot be directly transmitted between segment registers. MOV IP, 2000 H; this is wrong
(3) CS and IP cannot be used as target operands. MOV CS, AX; this is wrong
(4) The immediate number in the MOV instruction cannot be used as the target operand. MOV 2000H, [SI]; This is wrong
The MOV instruction can transfer words or bytes within the CPU or between the CPU and the memory. The information it transmits can be from registers to registers, counted immediately to registers, counted immediately to memory units, from memory units to registers, from registers to memory units, from registers or memory units to segment registers other than CS (note that instant numbers cannot be sent directly to segment registers), from segment registers to registers or memory units.
But pay attention
*(1) The source operand in the MOV instruction must not be an immediate number and code segment CS register;
(2) It is absolutely not allowed to directly transmit data between two storage units in the MOV instruction;
(3) It is absolutely not allowed to directly transmit data between two segment registers in the MOV instruction;
(4) The MOV command will not affect the flag bit*
Example: MOV AX, DATA_SEG
MOV DS,AX
Note: The segment register (segment address) must be initialized immediately through registers such as the AX register.
Example: MOV AL, ‘E’
Send the immediate number (ASC code of character E) to the AL register.
Example: MOV BX, OFFSET TABLE
Send the offset address of TABLE (not content) to the BX register. Where OFFSET is the attribute operator, which means that the value of the symbol address (not the content) is taken as the operand.
Example MOV AX, Y[BP][SI]
Send the contents of the memory unit with the address 16d×(SS)10(BP)10(SI)100 displacement Y to the AX register
PS: Let's take a look at the basic usage of mov instructions in the assembly
mov S ,D transmits D to S , or S to D?
In Wang Shuang's "Compilation": mov ax, 18 is to transfer 18 to the register ax.
But I disassemble the following functions using gcc
int test() { return 2; }
The assembly code obtained is
_add: LFB7: .cfi_startproc movl $2, %eax ;//Copy the eax content into 2? ? ? Obviously not right ret .cfi_endproc
Summarize
The above is the assembly language mov instructions and basic usage introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!