assume cs:fuck,ds:data,es:table
data segment
db '1975','1976','1977','1978','1979','1980','1981','1982','1983'
db '1984','1985','1986','1987','1988','1989','1990','1991','1992'
db '1993','1994','1995'
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
dw 11542,14430,45257,17800
data ends
stack segment
db 16 dup (0)
stack ends
fuck segment
start:
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov ax,stack
mov ss,ax
mov bx,0
mov bp,0
mov si,0
mov dx,0
mov di,0 ;初始化各个值
mov cx,21 ;总循环21次
qb: push cx ;保存总体循环次数
mov ah,7 ;设置属性
mov al,[bx]
mov es:[bp+6],ax
mov al,[bx+1]
mov es:[bp+8],ax
mov al,[bx+2]
mov es:[bp+10],ax
mov al,[bx+3]
mov es:[bp+12],ax ;年份进入显示区
mov ax,54h[bx]
mov dx,56h[bx] ;;因为是四字节,所以分AX和BX存储,刚好合除法位置
push si
mov si,1ch ;设置收入列偏移
call toc
pop si
mov ax,0a8h[di]
push si
mov si,2eh
call toc
pop si
;下面开始求平均收入
mov ax,54h[bx] ;因为是四字节,所以分AX和BX存储,刚好合除法位置
mov dx,56h[bx]
mov cx,word ptr [di+0a8h] ;除数
call divdw
push si
mov si,3ch ;设置列偏移
call toc
pop si
add bp,0a0h ;这里为换行做准备,下面都是
add bx,4
add di,2
pop cx
loop qb
mov ax,4c00h
int 21h
toc: ;子程序
push bx
push di
mov di,0 ;初始化di,我用di作为存储除法次数,后面出栈要用到
mov bx,10d ;设置除数为10d
t1:push ax ;从这里开始
mov ax,dx
mov dx,0
div bx
mov cx,ax
pop ax
div bx
add dx,30h
push dx
mov dx,cx
mov cx,ax
inc di
jcxz ok
jmp short t1 ;到这里,是解决除法溢出那个子程序
ok:mov cx,di ;把次数传送给cx,下面出栈要用
t2:pop dx ;开始出栈罗,
mov dh,7
mov es:[bp+si],dx ;开始送如显示缓冲区
add si,2 ;列偏移往前推
loop t2
pop di
pop bx
mov dx,0
ret ;执行完毕
divdw:push bx ;隔了几天做出来,都忘了这里的存在了,解决除法溢出的子程序
push cx ;用来计算平均值的
push ax
mov ax,dx
mov dx,0
div cx
mov bx,ax
pop ax
div cx
mov cx,dx
mov dx,bx
pop cx
pop bx
ret
fuck ends
end start