assume cs:codesg,ds:datasg,es:table,ss:stack
table segment
db '1975','1976','1977','1978','1979','1980','1981','1982','1983'
db '1984','1985','1986','1987','1988','1989','1990','1991','1991'
db '1993','1994','1995'
;以上是表示21年的21个字符串
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2795000,3753000,4649000,5937000
;以上是表示21年公司总收入的21个dword型数据
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
dw 11542,14430,15257,17800
;以上是表示21年公司雇员人数的21个word型数据
dw 5,3,42,104,85,210,123,111,105,125,140,136,153,211,199,209,224,239
dw 260,304,333
;以上是表示21年公司人均收入
dd 10 dup (0)
table ends
datasg segment
db 1000 dup (0)
datasg ends
stack segment
db 100 dup (0)
stack ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov ax,table
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov cx,21 ;21次循环为总收入转换ASCII码
s7: call dtoc
add bp,16 ;bp加16换行
add di,4 ;si+4
loop s7
mov ax,datasg
mov ds,ax
mov ax,table
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov cx,21 ;21次循环为总人数转换ASCII码
s8: call dtoc1
add bp,16 ;bp加16换行
add di,2 ;si+2
loop s8
mov ax,datasg
mov ds,ax
mov ax,table
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov cx,21 ;21次循环为平均收入转换ASCII码
s9: call dtoc2
add bp,16 ;bp加16换行
add di,2 ;si+2
loop s9
mov ax,datasg
mov ds,ax
mov ax,table
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov cx,21 ;21次循环年份
s10: call dtoc3
add bp,16 ;bp加16换行
add di,4 ;di+4
loop s10
mov ax,datasg
mov ds,ax
mov ax,0B800h
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov dh,4
mov dl,3
mov cx,21
s11: call show_str
add bp,16
add dh,1
loop s11
mov ax,datasg
mov ds,ax
mov ax,0B800h
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov dh,4
mov dl,14
mov cx,21
s12: call show_str1
add bp,16
add dh,1
loop s12
mov ax,datasg
mov ds,ax
mov ax,0B800h
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov dh,4
mov dl,28
mov cx,21
s13: call show_str2
add bp,16
add dh,1
loop s13
mov ax,datasg
mov ds,ax
mov ax,0B800h
mov es,ax
mov si,0
mov bp,0
mov di,0
mov ax,stack
mov ss,ax
mov sp,100
mov dh,4
mov dl,40
mov cx,21
s14: call show_str3
add bp,16
add dh,1
loop s14
mov ax,4c00h
int 21h
dtoc:
push cx
push di
push si
push bp
;cx、si入栈
s4:
mov ax,es:[di+54h]
mov dx,es:[di+56h]
mov bx,10
s1: mov bp,ax ;转移到L位
mov ax,dx ;dx值等于ax
xor dx,dx ;-----------H转AX D清零
div bx ;H除以bx
mov di,ax ;H结果=di
mov ax,bp ;ax植出栈,L重赋给ax
div bx ;-----------REG+L/10 DX=余娄 H结果=DI
;=========== L结果AX
mov cx,bp ;商为零cx
jcxz d_wk ;-----------余数为空jmp 到出栈
add dx,30h
push dx
inc si
xor dx,dx
;------------余数+30H=ASCII
mov dx,di
;------------H重赋给DX
jmp s1
;------------判断H为0,不为0循环
;============ 为0做L位除法
d_wk: mov cx,si
;------------设定循环数
;------------CX为0 jmpECS
jcxz s3 ;cx为零转移到s2
mov si,0
mov di,0 ;di等于0
s3: pop ax ;dx植出栈放入ax
mov es:[di+100h],al ;[bp+di+05h]=al
add di,1 ;di加1
loop s3 ;loop 循环
pop bp
mov cx,di
s2: mov al,es:[si+100h]
mov ds:[si+bp+05h],al
add si,1
loop s2
okay: pop si
pop di
pop cx
ret
dtoc1: ;除以十得到余数加30H
push cx
push di
push si
push bp
;cx、si入栈
sl4: mov ax,es:[di+0a8h]
mov bx,0
sl1: mov cx,10d
mov dx,0
div cx
mov cx,ax
jcxz sl2
add dx,30h
push dx
inc bx
jmp short sl1
sl2: add dx,30h
push dx
inc bx
mov cx,bx
mov si,0
sl3: pop ax
mov es:[si+100h],al
inc si
loop sl3
pop bp
mov di,0
mov cx,si
sl5: mov al,es:[di+100h]
mov ds:[di+bp],al
add di,1
loop sl5
okay1:
pop si
pop di
pop cx
ret
dtoc2: ;21年平均收入
;除以十得到余数加30H
push cx
push di
push si
push bp
;cx、si入栈
sd4: mov ax,es:[di+0d2h]
mov bx,0
sd1: mov cx,10d
mov dx,0
div cx
mov cx,ax
jcxz sd2
add dx,30h
push dx
inc bx
jmp short sd1
sd2: add dx,30h
push dx
inc bx
mov cx,bx
mov si,0
sd3: pop ax
mov es:[si+100h],al
inc si
loop sd3
pop bp
mov di,0
mov cx,si
sd5: mov al,es:[di+100h]
mov ds:[di+bp+0ch],al
add di,1
loop sd5
okay2:
pop si
pop di
pop cx
ret
dtoc3: ;21年年份放入ds段中
push cx
push di
push si
push bp
sw4: mov ax,es:[di]
mov dx,es:[di+2]
mov di,0
pop bp
mov ds:[bp+150h],ax
mov ds:[bp+152h],dx
okay3:
pop si
pop di
pop cx
ret
show_str:mov ax,0A0h
mul dh
mov bx,ax
mov ax,2
mul dl
sub ax,2
add bx,ax
mov di,0
mov al,ds:[bp+150h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+151h]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+152h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+153h]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
ok: ret
show_str1: ;显示21年总收入
mov ax,0A0h
mul dh
mov bx,ax
mov ax,2
mul dl
sub ax,2
add bx,ax
mov di,0
mov al,ds:[bp+5h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+6h]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+7h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+8h]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+9h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+0Ah]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+0Bh]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
okwy:
ret
show_str2: ;显示21年总人数
mov ax,0A0h
mul dh
mov bx,ax
mov ax,2
mul dl
sub ax,2
add bx,ax
mov di,0
mov al,ds:[bp]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+1h]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+2h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+3h]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+4h]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
okwl:
ret
show_str3: ;显示21年人均收入
mov ax,0A0h
mul dh
mov bx,ax
mov ax,2
mul dl
sub ax,2
add bx,ax
mov di,0
mov al,ds:[bp+0ch]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
add di,2
mov ah,ds:[bp+0dh]
mov es:[bx+di],ah
mov byte ptr es:[bx+di+1],02h
add di,2
mov al,ds:[bp+0eh]
mov es:[bx+di],al
mov byte ptr es:[bx+di+1],02h
okyok:
ret
codesg ends
end start