DF Flag and string move instruction (MOVSB/MOVSW)

Source: Internet
Author: User
Tags processing instruction

1.10th bit DF of the flag register, direction sign bit. In the string processing instruction, control the increment and decrement of si,di after each operation

Df=0, after each operation, Si, di increases

Df=1, after each operation, Si, di decreases

We can use the assembly syntax to describe the functions of MOVSB as follows:

mov es:[di],byte ptr ds:[si]; 8086 does not support such instructions, only for the purposes of description

If Df=0:inc si

Inc di

If Df=1:dec si

Dec di

As you can see, the function of MOVSB is to feed the bytes in the memory unit pointed to by Ds:si into Es:di, and then increment or decrement the SI and Si according to the value of the flag register DF bit.

2.rep

In general, MOVSB are used in conjunction with rep, in the following format: Rep MOVSB

Use the assembly syntax to describe:

S:mov SB

Loop s

See the role of rep is based on CX values, Executes the subsequent string transfer instructions repeatedly. Because the MOVSB will increment or decrement a memory unit without executing the SI/DI, then the rep movsb can loop through the transfer of (CX) characters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.