assume cs:code,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'
;data:54h
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
;data:0a8h
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
code segment
start:
call nf
call sr
call gy
call rjsr
mov ax,4c00h
int 21h
nf:
push ax
push ds
push es
push bx
push si
push cx
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov bx,0
mov si,0
mov cx,21
nf1:
push cx
mov cx,4
nf0:
mov al,[bx]
mov es:[si],al
mov byte ptr es:[si+1],2
inc bx
add si,2
loop nf0
add si,98h
pop cx
loop nf1
pop cx
pop si
pop bx
pop es
pop ds
pop ax
ret
sr:
push ax
push bx
push cx
push dx
push ds
push es
push si
push di
push bp
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov bx,0h
mov si,54h
mov di,20h
mov bp,0
mov cx,21
sr4:
push cx
push di
mov dx,[si+2]
mov ax,[si]
sr1:
mov cx,10
call divdw
add cx,30h
push cx
inc bp
mov cx,ax
jcxz sr0
jmp short sr1
sr0:
mov cx,dx
jcxz sr2
jmp short sr1
sr2:
mov cx,bp
sr3:
pop [bx]
inc bx
loop sr3
mov bx,0
mov ch,0
sr6:
mov cl,[bx]
jcxz sr5
mov es:[di],cl
mov byte ptr es:[di+1],2
inc bx
add di,2
jmp short sr6
sr5:
add si,4
pop di
add di,0a0h
mov bx,0
mov bp,0
pop cx
loop sr4
pop bp
pop di
pop si
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
ret
divdw:
;功能:进行不会产生溢出的除法运算,被除数为dword型,除数为word型,结果为dword型。
;参数:(ax)=dword型数据的低16位,(dx)=dword型数据的高16位,(cx)=除数。
;返回:(dx)=结果的高16位,(ax)=结果的低16位,(cx)=余数。
push bx
push ax
mov ax,dx
mov dx,0
div cx
mov bx,ax
pop ax
div cx
mov cx,dx
mov dx,bx
pop bx
ret
gy:
push ax
push bx
push cx
push dx
push ds
push es
push si
push di
push bp
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov bx,0
mov si,0a8h
mov di,40h
mov bp,0
mov cx,21
gy1:
push cx
push di
mov ax,[si]
mov dx,0
gy0:
mov cx,10
call divdw
add cx,30h
push cx
inc bp
mov cx,ax
jcxz gy3
jmp short gy0
gy3:
mov cx,dx
jcxz gy2
jmp short gy0
gy2:
mov cx,bp
gy4:
pop [bx]
inc bx
loop gy4
mov bx,0
mov ch,0
gy6:
mov cl,[bx]
jcxz gy5
mov es:[di],cl
mov byte ptr es:[di+1],2
inc bx
add di,2
jmp short gy6
gy5:
add si,2
pop di
add di,0a0h
mov bx,0
mov bp,0
pop cx
loop gy1
pop bp
pop di
pop si
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
ret
rjsr:
push ax
push bx
push cx
push dx
push ds
push es
push si
push di
push bp
mov ax,data
mov ds,ax
mov ax,0b800h
mov es,ax
mov bx,0
mov si,54h
mov di,0a8h
mov cx,21
rjsr1:
push cx
mov ax,[si]
mov dx,[si+2]
mov cx,[di]
call divdw
mov [bx],ax
mov [bx+2],dx
add si,4
add di,2
add bx,4
pop cx
loop rjsr1
mov bx,0
mov si,0
mov di,60h
mov bp,0
mov cx,21
rjsr7:
push cx
push di
mov ax,[si]
mov dx,[si+2]
rjsr0:
mov cx,10
call divdw
add cx,30h
push cx
inc bp
mov cx,ax
jcxz rjsr3
jmp short rjsr0
rjsr3:
mov cx,dx
jcxz rjsr2
jmp short rjsr0
rjsr2:
mov cx,bp
rjsr4:
pop [bx]
inc bx
loop rjsr4
mov bx,0
mov ch,0
rjsr6:
mov cl,[bx]
jcxz rjsr5
mov es:[di],cl
mov byte ptr es:[di+1],2
inc bx
add di,2
jmp short rjsr6
rjsr5:
add si,4
pop di
add di,0a0h
mov bx,0
mov bp,0
pop cx
loop rjsr7
pop bp
pop di
pop si
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
ret
code ends
end start