解题思路
代码
在dos环境下使用masm编译测试通过
assume cs:codesg
data segment
db '1975','1976','1977','1978','1979','1980'
dd 16,22,382,1356,2390,2391
dw 3,7,9,13,28,29
data ends
table segment
db 6 dup ('year summ ne ?? ')
table ends
stack segment
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
stack ends
codesg segment
start:
mov ax,data
mov ds,ax
mov ax,table
mov es,ax
mov ax,stack
mov ss,ax
mov sp,32
;初始化
;这里定义的循环次数需要和数据长度一直
mov cx,6
mov di,0
mov bx,0
mov bp,0
mov si,0
s:
push cx
push bp
;year
mov cx,4
mov bp,0
s1:
mov al,ds:[bx]
mov es:[bp+di],al
inc bx
inc bp
loop s1
;summ
pop bp
;暂存di 这里暂存di是因为除法用到了di寄存器,