assume cs:codesg
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
dw 5,3,42,104,85,210,123,111,105,125,140,136,153,211,199,209,224,239
dw 260,304,333
data ends
stack segment ;把段定义为空格为了输出的时候方便输出、对齐
db 300 dup (' ')
stack ends
codesg segment
start: mov dh,0 ;行数
mov dl,60 ;列数
mov ax,0b800h
mov bx,dx ;因为把数据显示在0行,所以可以直接赋值就行
mov es,ax ;ax和dx在下面可任意赋值了
mov di,0
;*********
mov ax,data
mov ds,ax
mov si,0
;*********
mov ax,stack
mov ss,ax
mov sp,200
mov bp,100
mov dx,21
s6: mov cx,4 ;存年份
s5: mov al,[si] ;si==0 -> si ==4
mov [bp],al
inc si
inc bp
loop s5
mov ax,0
mov cx,6
mov bp,100 ;恢复bp的值,以备调用show_str用
call show_str ;把年份放到显存
add bx,160
mov ax,0
mov cx,dx
sub dx,1
mov bp,100 ;恢复bp以备从新把值送进栈
loop s6
;*********************当上面那些代码运行完时,si指向了data段中的dd的开始
;*********************并且di=6
mov di,21 ;这段代码中不要忘了bp=100
mov bx,60
add bp,4 ;这样就可以把之前的年份覆盖掉
s7: mov ax,[si] ;公司总收入
add si,2
mov dx,[si]
call divdw
mov cx,10
mov ax,6 ;ax作为中介
call show_str
add bx,160
mov ax,6 ;ax作为中介
add si,2
mov cx,di
sub di,1
loop s7
;******************di=001ah
mov bx,0
mov ax,4c00h
int 21h
;***********************
;功能:实现不溢出的除法运算,并把余数推进栈
divdw: push bx
push cx
push di
push ax
mov bx,10
did:mov ax,dx
mov dx,0
div bx
mov di,ax ;保存高位的商
pop ax
div bx
add dl,30h
mov [bp],dl
sub bp,1
mov cx,ax
push ax
mov dx,di
jcxz next
jmp short did
next:inc bp
pop ax
pop di
pop cx
pop bx
ret
;**********************
;功能:把字符放进显示缓冲区
show_str: push bx
push dx
push es
push ds
push di
;push si
push cx
pop cx
mov di,ax
str1: mov al,[bp] ;存放字符
mov ah,2 ;存放颜色
mov word ptr es:[bx+di],ax
inc bp
add di,2
loop str1
;pop si
pop di
pop ds
pop es
pop dx
pop bx
ret
codesg ends
end start