[BX]
Because in the compiler mov ax,[0] instruction will be considered by the compiler to be MOV ax,0 so introduced the concept of [BX]
mov [bx],ax means to assign the value of the (DS) *16+ (BX) memory location to Microsoft Dynamics AX
Use the same as before Ds[address]
Small Tips
1 ;How to use [BX]2 movax,1000h3 4 movbx,2000h5 6 movDs,ax;assign a value of 2000H to the DS Data segment register7 8 mov[Bx],ax;assign the value of the AX register to the memory unit 21000H location9 Ten ;Other ways One movAxds:[0];assign the value of the memory Unit 20000H location to Microsoft Dynamics AX
Loop command (Loop)
The format of the directive is: loop designator, when the CPU executes the Loop command, two steps are taken:
① (CX) = (CX)-1;
The ② determines the value in CX, does not zero, and then goes to the label to execute the program, and if zero, executes down.
Usually we use loop instruction to realize the loop function, thenumber of cycles stored in CX.
Example: Using a program to calculate 211
1AssumeCS:Code2 Code Segment3 Start:movAx24 movCx One ;set the number of cycles to one5 S: AddAx,ax;each time the operation is performed, the Cx-16Loop s;verifies that the value of CX is 0, executes the following program for 0, or jumps back s (s can be any string) to execute7 movax,4c00h;Program returns8 int21h9Code ends;end of code snippetTenEnd Start
Example 2: Calculate 123 x236 with addition, the result exists in AX.
1AssumeCS:Xinge;Locate the code snippet,2Xinge segment;The code snippet can be any name3 Start:movAx04 movCx1235 Jiaxin:6 AddAx236 ;operations to Loop on7 Loop Jiaxin8 movax,4c00h9 int21hTen code ends OneEnd Xinge
Combined application of loop and [BX]
Thinking: Computes the ffff:0~ffff:b of the data in the cell and stores the results in DX.
First look at a wrong: The cause of the error, only defined dl++, overflow does not carry
1AssumeCS:Code2 Code Segment3 Start: movAx,0ffffh;The compiler does not support the beginning of a letter4 movDs,ax5 movBx06 movDl07 movDh08 movCx A9 Ten S:AddDL,[BX] One IncBX A Loop S - - movax,4c00h the int + - code ends -End Start
The right
1AssumeCS:Code2 Code Segment3 Start: movAx,0ffffh;The compiler does not support the beginning of a letter4 movDs,ax5 movBx06 movDx07 movCx A8 9 S:movAL,[BX];assign value to lowTen movAh0 One AddDx,ax;add with 16 bits so that it does not overflow A IncBX - Loop S - the movax,4c00h - int + - code ends -End Start
Segment Prefix
The "DS:", "CS:", "SS:", or "es:" that appear in the instruction that accesses the memory unit to explicitly indicate the segment address of the memory unit, called the segment prefix in assembly language.
Use of segment prefixes:
Example: Copy data from a memory ffff:0~ffff:b segment into a 0:200~0:20b cell.
Method One: Continuously modify the DS value and then assign the value
Method Two: Use the segment prefix es: (es is the extra segment register), so that you can eliminate the constant change in the DS value
1AssumeCS:Code2 Code Segment3 movcx,40h;cycle times, 3f+14 movAx05 movDs,ax6 movbx,200h7 movDx08 S:9 mov[Bx],dxTen IncDX One Loop S A - movax,4c00h - int21H the code ends -End
answer to the first question
1AssumeCS:Code2 Code Segment3 movcx,40h4 movAx - ;another address changed to5 movDs,ax6 movBx0 ;BX can start from 0, the same as to push the value of the memory unit7 S:8 mov ds:[Bx],bx9 IncBXTen Loop S One A movax,4c00h - int21H - code ends theEnd
answer to the second question
Assembly language--[BX] and loop instructions