Question

What x86 register denotes source location in movsb instruction?

Was it helpful?

Solution

In 32-bit mode, esi.

In specific, movsb copies one byte from ds:esi to es:edi, the adjusts both esi and edi by 1, either up or down depending on the direction flag.

OTHER TIPS

How to extract that information from the manual

Now that you've logged into osdev.org, it's time to pay your moral debt by actually learning it. :-)

Intel Manual Volume 2 Instruction Set Reference - 325383-056US September 2015 section "MOVS/MOVSB/MOVSW/MOVSD/MOVSQ—Move Data from String to String" says:

Moves the byte, word, or doubleword specified with the second operand (source operand) to the location specified with the first operand (destination operand). Both the source and destination operands are located in memory. The address of the source operand is read from the DS:ESI or the DS:SI registers

Minimal test program

Finally, you must make a minimal program that uses the instruction to see if you've understood it correctly:

section .data
    src db 0
    dest db 1
section .text
global _start
_start:
    mov esi, src
    mov edi, dest
    cld
    movsb
    /* dest == 0*/

Runnable version of this with assertions on GitHub.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top