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