# `movsq`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/movsq

**Move string quadwords**

Category: Block and string

Copies the quadword at [rsi] to [rdi], then advances rsi and rdi by 8, backward when DF is set.

x86-64 and later

[Intel's reference: MOVS/MOVSB/MOVSW/MOVSD/MOVSQ](https://intel.github.io/SDM/instruction/MOVS-MOVSB-MOVSW-MOVSD-MOVSQ.html)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | not changed |
| OF | not changed |

Reads: DF

## Forms

- `movsq`

## Description

The q suffix selects an element of 8 bytes. After each element, the instruction increases `rsi` and `rdi` by 8 when DF = 0, or decreases `rsi` and `rdi` by 8 when DF = 1. In 64-bit mode the default addresses use `rsi` and `rdi`. The `a32` address-size prefix instead uses `esi` and `edi`; 16-bit string addressing is unavailable.

`rep` repeats until the counter reaches zero. The counter is `rcx` by default or `ecx` with `a32`. If it starts at zero, a repeated instruction accesses no element. The data width is independent of this address and counter width.

## Example

```x86
global _start

section .data
source: db 1, 2, 3, 4, 5, 6, 7, 8
destination: times 8 db 0

section .text
_start:
        cld                 ; count upwards
        mov rsi, source
        mov rdi, destination
        mov rax, 7
        movsq               ; copies eight bytes

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall
```
