assume cs:code,ds:data
data segment
db '1975','1976','1977','1978','1979','1980','1981'
db '1982','1983','1984','1985','1986','1987','1988'
db '1989','1990','1991','1992','1993','1994','1995'
;年份(0-53h)
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
;收入,起始单元:(54-A7h)
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
dw 11542,14430,15257,17800
;人数,起始单元:(A8)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,0b800h
add ax,0ah
mov es,ax
mov bx,0
mov di,0
mov si,0
mov cx,21
s:push cx
push si
push di
push bx
mov ah,7;设置颜色属性
mov al,[si]
mov es:[di+0],ax;年份第一字节和属性
mov al,[si+1]
mov es:[di+2],ax;年份第二字节和属性
mov al,[si+2]
mov es:[di+4],ax ;年份第三字节和属性
mov al,[si+3]
mov es:[di+6],ax;年份第四字节和属性
add di,40;空了20格
mov ax,[si+54h]
mov dx,[si+56h]
call gy;显示收入
mov ax,[bx+0a8h]
mov dx,0
call gy;显示人数
mov ax,[si+54h]
mov dx,[si+56h];被除数
mov cx,[bx+0a8h];除数
call divdw;求平均数
call gy;显示平均数
pop bx
pop di
pop si
pop cx
add bx,2
add si,4
add di,160
loop s
mov ax,4c00h
int 21h
gy:push di
push bx
mov bp,0
gy1:push ax
mov ax,dx
mov dx,0
mov bx,10
div bx
mov cx,ax
pop ax
div bx
add dx,30h;把余数加30H变成字符
push dx;字符入栈
inc bp;记录入栈的数量
mov dx,cx;把高16位的值给DX
mov cx,ax;把商给cx,
jcxz ok1
jmp gy1
ok1:mov cx,bp
gy2:pop dx
mov dh,7;因为pop dx的值一定小于除数10,所以dh是0
mov es:[di],dx
add di,2
loop gy2
pop bx
pop di
add di,40;空了20格
ret
divdw:push ax
mov ax,dx
mov dx,0
div cx;高16位的计算,相当于ax=0fh,dx=0h
mov bx,ax;相当于int(H/N)*65536,商给bx
pop ax
div cx;想当于,ax=4240h,dx=5(rem(H/n)*65536)
mov cx,dx;cx相当于余数
mov dx,bx;dx的值就是,int(H/N)*65536
;ax的值就是,[rem(H/n)*65536+L]/n
ret
code ends
end start
哈哈,终于写对了,分享下 我的代码,