Analysis: 1. 0:200~0:23F is actually the same memory space as 0020:0~0020:3F .
2. Use BX to store the offset address,The dx register is used as a container for storing intermediate variables (source data, constants 0-63 ) to write to memory.
The corresponding program code:
code segment
mov ax,0020h
mov ds,ax
mov bx,0
mov ax,0
mov cx,64
s:mov ds:[bx],ax
inc bx
inc ax
loop s
mov ax,4c00h
int 21h
end
After compiling and linking, an executable file is generated, loaded with debug, and its operation is tracked, as shown in the figure:
Example 2. Transfer data 0~63(3FH) to memory 0:200~0:23F in sequence, the program can only use 9 instructions, 9 instructions include "MOV AX 4C00H" and "INT 21H" (return instruction)
Analysis: Data 0-63 are 64 consecutive numbers, and 0-3fH are also 64 consecutive numbers. You can use a bx variable to represent both the offset address and the increment of the number
The program code is as follows:
code segment
mov ax,0020h
mov ds,ax
mov bx,0
mov cx,64
s:mov ds:[bx],bx
inc bx
loop s
int 21h
code ends
end
After compiling and linking, an executable file is generated, loaded with debug, and its operation is tracked, as shown in the figure: