this is the right codeI then this code inside a data and a table, with es and ds to store their address, but if the store their segment address of the segment registers swaps (behind the code also corresponding swaps) then I will go wrong, the source code is executed 21 times circulation, swap the segment registers after only six normal execution cycle, cycle die cycle for the seventh time the
What is this
Oh, there is a si and di, if the swap the ds and es, behind the add si in the code and add di when they increase the value of the corresponding also swap
assume cs: code
The data segment
The db '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983'
The db '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992'
The db '1993', '1994', '1995'
Dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
Dd, 345980590, 827803, 530118000184000275000375000464000593000
Dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
Dw, 11542144, 30152, 57178 00
The data ends
Table segment
The db 21 dup (' year summ ne?? ')
The table ends
Code segment
Start:
Mov ax, table
Mov ds, ax
Mov ax, data
Mov es, ax
Mov di, 0
Mov si, 0
Mov bx, 0
Cx, mov 21
S:
Mov ax, es: [di]
Mov ds: [bx + 0], ax
Mov ax, es: [di + 2]
Mov ds: [bx + 2], ax
Mov ax, es: [54 h + di]
Mov ds: [bx + 5 h], ax
Mov ax, es: [56 h + di]
Mov ds: [bx + 7 h], ax
Mov ax, es: [0 a8h + si]
Mov ds: [bx + 0 ah], ax
Mov ax, ds: [bx + 5 h]
Mov dx, ds: [bx + 7 h]
Div word PTR ds: ah [bx + 0]
Mov ds: [bx + 0 dh], ax
The add bx, 10 h
The add si, 2
The add di, 4
Loop s
Mov ax, 4 c00h
Int 21 h
Code ends
The end start
CodePudding user response:
Mov ax, es: [0 a8h + si]Mov ds: [bx + 0 ah], ax
CodePudding user response:
Help you find an explanation forCS and DS is the so-called segment registers, a program is divided into several segments, and often keep the code base address in the CS, DS the base address of the data segment is saved, division of labor is clear