assume cs:codesg
codesg segment
xjazz: mov ax, 2000H ;ax=2000H
mov ds, ax ;ds=ax=2000H
mov bx, 1000H ;bx=1000H
mov ax, [bx] ;将偏移地址1000处存储的数据赋值给AX
;即将物理地址ds:1000处(即2000:1000处)存储的值给AX
inc bx ;bx自增1,即bx++
inc bx ;两次自增完成后bx=1002
mov [bx], ax ;将AX存储的值赋值到物理地址ds:1002处
inc bx
inc bx
mov [bx], ax ;将AX存储的值赋值到物理地址ds:1004处
inc bx ;bx++; bx=1005
mov [bx], al ;将AL的值赋值给物理地址ds:1005
inc bx
mov [bx], al ;将AL的值赋值给物理地址ds:1006
mov ax, 4c00H
int 21H
codesg ends
end xjazz
The 8086 microcomputer uses the segment address + offset address to represent the physical address. For example, the physical address (representation) that appears in this example: 2000: 1000, 2000: 1002, 2000: 1004, 2000: 1005, and 2000: 1006 correspond to the actual physical Address 21000, 21002, 21004, 21005, 21006.
To explain in detail, the segment (base) address is in front of the colon, and the offset address is after the colon. The physical address actually expressed is the segment address multiplied by 16 plus the offset address, and multiplied by 16 in hexadecimal is one digit.
Inc is the self-increasing instruction in assembly language, which is equivalent to "++" in C / C ++ language, which is why ++,-in C / C ++ language is faster than +1, -1 Increment and decrement operations have direct corresponding assembly instructions.
ps: As common sense, you should know that when a compiler compiles a program written in a high-level language, it first translates the high-level language code into the corresponding assembly instruction, and then converts the assembly instruction into the corresponding machine code for execution.