|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
将data 段的数据处理成对应数字的ASC 码,然后存到table段,然后输出,没有处理求平均收入那行,大家看看怎么回事,我做的这个,只能将data段的前三行存入,第四行就会出错,前三行正常,代码如下:
assume cs:code,es:table,ss:stack,ds:data
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 21 dup (' ')
table ends
stack segment
dw 16 dup (0)
stack ends
code segment
start: mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,32
mov ax,table
mov es,ax
mov di,0
mov bp,0
mov bx,0
mov cx,21
s1: mov si,0 //实现了,data 段数据处理成ASC 码之后向table 传送
mov ax,ds:[0+di]
mov es:[bx+si],ax
mov ax,ds:[di+2]
mov es:[bx+si+2],ax
mov si,10
mov ax,ds:[84+di]
mov dx,ds:[86+di]
call ddwtoc
mov si,20
mov ax,ds:[168+bp]
call dtoc
add bx,40
add di,4
add bp,2
loop s1 //到此传送完毕
mov ax,table //从这开始将table 数据输出到显示器,每类数据用10字节,不足补空格,显示美化
mov ds,ax
mov si,0
mov dh,1
mov dl,0
l: mov cl,2
call show
inc dl
inc si
cmp dl,40
je q
jmp l
q: inc dh
mov dl,0
cmp dh,22
jne l
jmp over
over: mov ax,4c00h
int 21h //到此显示完成
ddwtoc: push ax //将双字的数据转化成ASC码
push dx
push bx
push cx
push si
push di
mov di,0
s: mov cx,10
call divdw
mov ch,0
add cx,30h
push cx
inc di
mov cx,ax
jcxz d1
jmp s
d1: mov cx,dx
jcxz okk
jmp s
okk: mov cx,di
rev: pop ax
mov es:[bx+si],al
inc si
loop rev
pop di
pop si
pop cx
pop bx
pop dx
pop ax
ret //到此双字数据转化ASC码 的功能完成
dtoc: push dx //将字数据转化成ASC码
push bx
push cx
push si
push di
mov di,0
mov cx,10
ms: mov dx,0
div cx
mov dh,0
add dx,30h
push dx
inc di
mov cx,ax
jcxz ok
jmp ms
ok: mov cx,di
pop ax
mov es:[bx+si],al
inc si
loop ok
pop di
pop si
pop cx
pop bx
pop dx
ret //到此将字数据转化成ASC码 功能完成
divdw: push si //进行无溢出的除法运算
push ax
mov ax,dx
mov dx,0
div cx
mov si,ax
pop ax
div cx
mov cx,dx
mov dx,si
pop si
ret //无溢出的除法运算完成
show: push bx //向显示器显示数据
push es
push ax
push dx
push cx
mov di,0
mov ax,0b800h
mov es,ax
mov ax,0
mov al,0a0h
mul dh
mov dh,0
add dl,dl
add ax,dx
mov bx,ax
mov ch,0
mov cl,ds:[si]
mov es:[bx+di],cl
pop cx
mov es:[bx+di+1],cl
pop dx
pop ax
pop es
pop bx
ret //显示完成
code ends
end start
|
|