Compile learning notes for beginners (4) -- [BX] and loop commands

Source: Internet
Author: User

Getting started with crazy summer vacation Study Notes (4) -- [BX] and loop commands


Reference: Chapter 5th of Assembly Language


1. [BX]


MoV Al, [1]

In debug, data in BS: 1 is assigned to Al, but data in BS: 1 is not assigned to Al in MASM, instead, [1] is considered to be 1 assigned to Al.

If you want to implement mov Al, [1] In debug, you need [BX] In MASM.

For example:

MoV BX, 1

MoV Al, [BX]


You can also use BS: [1 ].

For example:

MoV Al, BS: [1]


2. Loop


Loop command should be used for Loop

Example: Calculate 2 ^ 20

assume cs:codesgcodesg segmentstart:mov ax,0mov cx,20s:add ax,2loop smov ax,4c00Hint 21Hcodesg endsend start


The number of times that CX stores loops. Each cycle minus 1

S indicates the start of the loop. The loop jumps to S. You can use DEBUG to debug the code above. Loop S is actually loop 0006 H.


3. Loop debugging in debug


You can run-G 000b (install the above Code for debugging) to stop the specified code to exit the loop.

Or use-P directly in the loop to jump out of the loop.


4. A security space


In general, 0: 200h ~ in DOS ~ 0: The 2ffh space does not have data or code of the system or other programs. It can be used.



5. Use of segment prefix


MoV Al, BS: [1]

BS: the segment prefix.

Not only BS can

MoV ax, DS: [BX]

MoV ax, CS: [BX]

MoV ax, SS: [BX]

MoV ax, ES: [BX]

Yes


Example: Put the memory FFFF: 0 ~ FFFF: Copy Data in Unit B ~ 020: f.

assume cs:codesgcodesg segmentstart:mov ax,0ffffhmov ds,axmov ax,0020Hmov es,axmov cx,12mov bx,0s:mov al,ds:[bx]mov es:[bx],alinc bxloop smov ax,4c00Hint 21Hcodesg endsend start









 

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.