|
楼主 |
发表于 2012-2-24 18:03:53
|
显示全部楼层
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
stack segment
db 32 dup(0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,32
mov di,0 ;读取数据起始偏移地址
mov bl,0 ;行数变量
mov cx,21 ;循环次数
;年份
dd_data:
push cx
mov cx,4
mov bp,0
s0:
mov al,[di]
mov [bp],al
inc di
inc bp
loop s0
mov byte ptr [bp],0
mov dh,5
add dh,bl
mov dl,23
mov cl,2
call show_str
pop cx
inc bl
loop dd_data
;收入
mov cx,21
mov bl,0
mov di,84
dd_data1:
push cx
mov ax,[di]
mov dx,[di+2]
call dtoc
mov dh,5
add dh,bl
mov dl,33
mov cl,2
call show_str
pop cx
inc bl
add di,4
loop dd_data1
;人数
mov cx,21
mov bl,0
mov di,168
dd_data2:
push cx
mov ax,[di]
mov dx,0
call dtoc
mov dh,5
add dh,bl
mov dl,43
mov cl,2
call show_str
pop cx
inc bl
add di,2
loop dd_data2
;人均工资
mov cx,21
mov bl,0
mov di,84
mov si,168
dd_data3:
push cx
mov ax,[di]
mov dx,[di+2]
div word ptr [si]
mov dx,0
call dtoc
mov dh,5
add dh,bl
mov dl,53
mov cl,2
call show_str
pop cx
inc bl
add di,4
add si,2
loop dd_data3
mov ax,4c00h
int 21h
dtoc:
push ax
push cx
push bp
push si
mov si,0
s1: mov cx,10
call divdw
add cx,30h
push cx
inc si
mov cx,ax
jcxz ok
jmp s1
ok:
mov bp,0
mov cx,si
s2:
pop ax
mov [bp],al
inc bp
loop s2
mov byte ptr [bp],0
pop si
pop bp
pop cx
pop ax
ret
divdw:
push bx
push ax ;将低16位数据暂存栈中
mov ax,dx ;将高16位数据给ax
mov dx,0 ;将余数清零避免干扰下面运算
div cx ;计算int(H/N)
mov bx,ax ;将int(H/N)暂存bx中
pop ax ;将低16位数据出栈给AX
div cx ;计算(L+rem(H/N)*65536)/N
mov cx,dx ;将余数给cx
mov dx,bx ;将结果高16位给dx
pop bx
ret
show_str:
push ax
push bx
push cx
push dx
push bp
mov ax,0b800h
mov es,ax
mov al,160 ;以下计算显示缓冲区的偏移地址
dec dh
mul dh
mov bx,ax
mov al,2
mul dl
sub dl,2
add bx,ax
mov bp,0
mov ah,cl
s:
mov cl,[bp]
mov ch,0
jcxz return
mov al,[bp]
mov es:[bx],ax
add bx,2
inc bp
jmp s
return:
pop bp
pop dx
pop cx
pop bx
pop ax
ret
code ends
end start |
|