以下是我实现的代码,为了减少代码,加快编程,数据量由21减少为4,仅供参考
assume cs:codeseg,ds:dataseg,es:table
dataseg segment
db '1975','1976','1977','1978'
dd 16,22,382,1356
dw 3,7,9,13
dataseg ends
table segment
db 4 dup ('year summ ne ?? ')
table ends
codeseg segment
start: mov ax,dataseg
mov ds,ax
mov ax,table
mov es,ax
mov cx,4
mov bx,0 ; for year,summ
mov bp,0 ; for ne
mov di,0 ; row in table
s: mov si,0
mov ax,[bx]
mov es:[di],ax
mov ax,[bx+2]
mov es:[di+2],ax
mov byte ptr es:[di+4],' ' ;year
add si,16
mov ax,[si+bx]
mov es:[di+5],ax ;low 16bits
mov ax,[si+bx+2]
mov es:[di+7],ax ;high 16bits
mov byte ptr es:[di+9],' ' ;summ
add si,16
mov ax,ds:[si+bp]
mov es:[di+10],ax
mov byte ptr es:[di+12],' ' ;ne
mov ax,es:[di+5]
mov dx,es:[di+7]
div word ptr es:[di+10]
mov es:[di+13],ax ;??
mov byte ptr es:[di+15],' ' ;??
add di,16
add bx,4 ; for year, summ
add bp,2 ; for ne
loop s
mov ax,4c00h
int 21h
codeseg ends
end start