9.3.2 Moving From Memory To Memory (movsx)

The movsx instructions are used to move a sequence of bytes from one memory location to another. The movsb instruction is used to move 1 byte from the address specified by the esi register to the address specified by the edi register. The movsw, movsd instructions move 2 and 4 bytes from the address specified by the esi to the address specified by edi. After the value is moved, the esi and edi registers are incremented/decremented by 1, 2, or 4 bytes, based on the size of the data item. In the following assembly code, let's assume that the address labeled as src contained the string "Good", followed by a null terminator (0x0). After executing the first instruction at ➊, esi will contain the start address of the string "Good" (in other words, esi will contain the address of the first character, G), and the instruction at ➋ will set EDI to contain the address of a memory buffer (dst). The instruction at ➌ will copy 1 byte (the character G) from the address specified by esi to the address specified by edi. After executing the instruction at ➌, both esi and edi will be incremented by 1to contain the next address:

 ➊ lea esi,[src] ; "Good",0x0
➋ lea edi,[dst]
➌ movsb

The following screenshot will help you to understand what happens before and after executing the movsb instruction at ➌. Instead of movsb, if movsw is used, then 2 bytes will be copied from src to dst, and esi and edi will be incremented by 2:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.23.123