assume cs:code
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,15257,17800
data ends
table segment
db 16 dup (0)
table ends
stack segment
dw 32 dup (0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,32
mov ax,data
mov es,ax
mov ax,table ;数据存放段.显存段已经在子程序中定义
mov ds,ax
mov bx,0
mov si,0
mov di,0
mov cx,21
mov dh,5
s:push cx
mov ax,es:[si] ;录入年份
mov [bx],ax
mov ax,es:2[si]
mov [bx].2,ax
mov byte ptr [bx].4,0 ;字符串的第4位是0
mov dl,3
mov cl,7
push dx
call show_str
mov ax,es:84[si] ;录入收入
mov [bx],ax
mov dx,es:86[si]
mov [bx].2,dx
call dtoc
pop dx
mov dl,20
mov cl,7
push dx
call show_str
pop dx
add si,4
add di,2
inc dh
pop cx
loop s
mov ax,4c00h
int 21h
divdw:
push bx
push si
mov bx,ax ;寄存原先地16位在ba
mov ax,dx
mov dx,0
div cx ;进行高16位除法,商在ax,余数在dx
mov si,ax ;将高16位除法的商存在si
mov ax,bx
div cx ;低十六位与原先高十六位除以cx的余数作为新的32位数,去除cx
mov cx,dx
mov dx,si ;
pop si
pop bx
ret
dtoc:
push bx
push si
push di
ok: mov cx,10
call divdw
push cx ;余数存在cx压栈
mov si,ax ;地位商存si,加上高位商dx.判断和是不是0
add si,dx
mov cx,si
inc di ;计算进行了多少次除法运算
jcxz ok0
jmp short ok
ok0: mov byte ptr [di],0 ;末尾加0
mov cx,di ;除法的次数赋予cx,循环
mov di,0
ok1: pop ax
add al,30h ;每次的余数出栈到ax
mov [di],al ;赋予ds段字符串
inc di ;di从0开始到cx
loop ok1
pop di
pop si
pop bx
ret
show_str:
push es
push ax
push bx
push si
push di
push cx
mov si,0
mov di,0
mov ax,0b800h
mov es,ax
mov al,160
dec dh
mul dh
mov bx,ax
mov al,2
dec dl
mul dl
mov di,ax
ko:
mov cl,[si]
mov ch,0
jcxz ko0
pop cx
push cx
mov ah,cl
mov al,[si]
mov word ptr es:[bx][di],ax
inc si
add di,2
jmp short ko
ko0: pop cx
pop di
pop si
pop bx
pop ax
pop es
ret
code ends
end start