做完王爽的《汇编语言》的课程设计1,出来秀一个
data segmentdb 24 dup(0)
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
dw 10 dup(0)
stack ends
code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,20
call show_str4
mov dh,0
mov dl,21
mov di,0
mov cx,21
s2: push cx
call dtostr
call show_str
inc dh
pop cx
loop s2
mov dh,0
mov dl,39
mov di,0
mov cx,21
s5: push cx
call wtostr
call show_wstr
inc dh
pop cx
loop s5
mov dh,0
mov dl,57
mov di,0
mov word ptr ds:[10],108
mov word ptr ds:[12],192
mov cx,21
s8: push cx
call retostr
call show_wstr
inc dh
pop cx
loop s8
mov ax,4c00h
int 21h
show_str4:
mov si,24
mov cx,21
mov dh,0
mov dl,3
mov ax,0b800h
mov es,ax
s1: push cx
mov al,0a0h
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
mov cx,4
s0: push cx
mov cl,7
mov al,ds:[si]
mov ah,cl
mov es:[bx],ax
add bx,2
inc si
pop cx
loop s0
inc dh
pop cx
loop s1
ret
dtostr: push dx
add di,2
mov ax,ds:[si]
mov dx,ds:[si+2]
s3: mov ds:[20],ax
mov ax,dx
mov dx,0
mov bx,10
div bx
mov ds:[22],ax
mov ax,ds:[20]
div bx
mov ds:[20],ax
add dx,30h
mov ds:[di],dx
mov dx,ds:[22]
add di,2
or word ptr ds:[22],0
jnz s3
or word ptr ds:[20],0
jnz s3
add si,4
pop dx
ret
show_str:
sub di,2
mov cl,7
mov ax,0a0h
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
s4: mov al,ds:[di]
mov ah,cl
mov es:[bx],ax
add bx,2
sub di,2
jnz s4
ret
wtostr:
push dx
inc di
mov ax,ds:[si]
s6: mov dx,0
mov bx,10
div bx
mov cx,ax
add dx,30h
mov ds:[di],dx
jcxz ok0
inc di
jmp short s6
ok0:
add si,2
pop dx
ret
show_wstr:
mov ax,0a0h
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
s7: mov al,ds:[di]
mov ah,7
mov es:[bx],ax
add bx,2
dec di
jnz s7
ret
retostr:
push dx
inc di
mov bx,ds:[10]
mov ax,ds:[bx]
mov dx,ds:[bx+2]
mov bx,ds:[12]
mov cx,ds:[bx]
div cx
mov cl,10
s9: div cl
add ah,30h
mov ds:[di],ah
inc di
cmp al,0
mov ah,0
jne s9
dec di
mov ax,ds:[10]
add ax,4
mov ds:[10],ax
mov ax,ds:[12]
add ax,2
mov ds:[12],ax
pop dx
ret
code ends
end start