Wang Shuang "assembly language" the third edition of the fifth chapter [BX] and loop instructions

Source: Internet
Author: User
Tags microsoft dynamics

5.1 [BX]

MOV ax,[bx] function: BX stored in the data as an offset address EA, the segment address SA by default in the DS, the data at Sa:ea is fed into Microsoft Dynamics AX.


5.2 Loop Command

The format of the directive is: loop designator, when the CPU executes the Loop command, two steps are taken:
1. (CX) = (CX)-1;
2. Determine the value in CX, not zero to go to the label to execute the program, if zero is executed down.

Usually we use loop instruction to realize the loop function, the number of cycles stored in CX.


5.3 Tracking Loop program implemented with loop instruction in debug


5.4 Debug and Assembler compiler MASM different handling of instructions

In the assembler meta-Program, the instruction "mov ax,[0]" is treated as a directive "MOV ax,0" by the compiler.

1.mov al, [0]
2.mov al, Ds:[0]
3.mov al, [BX]
4.mov al, Ds:[bx]


Combined application of 5.5 loop and [BX]


5.6 Segment Prefix

Instruction "mov ax,[bx]", the offset address of the memory unit is given by BX, and the segment address by default in the DS, we can access the memory unit in the instruction to explicitly give the memory unit segment address of the segment register.

The "DS:", "CS:", "SS:", or "es:" that are used to explicitly indicate the segment address of a memory unit, called a segment prefix in assembly language.


5.7 A safe space

In 8086 mode, it is dangerous to write to a memory space at will, as this space may contain important system data or code.

In a typical PC, DOS and other legitimate programs do not generally use the 256-byte space of 0:200~0:2FF (0:200H~0:2FFH) in a DOS mode. So, we use this space to be safe.


Use of 5.8-segment prefixes

Reference: "Small Turtle Collection 0 Basic Primer"

The third edition of Assembly language

Wang Shuang "assembly language" the third edition of the fifth chapter [BX] and loop instructions

Related Article

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.