| 
 | 
 
 
发表于 2024-10-28 18:17:20
|
显示全部楼层
 
 
 
 本帖最后由 jackz007 于 2024-10-29 13:50 编辑  
 
        楼主不妨试试这个代码: 
- assume cs:code,ds:data,es:table
 
  
- data segment para public 'DATA'
 
 -         db 400h dup(0)
 
 - data ends
 
  
- table segment para public 'TABLE'
 
 -         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
 
 -         dd 140417,197514,345980,590827,803530,1183000,1843000
 
 -         dd 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
 
 - table ends
 
  
- stack segment stack
 
 -         db 400h dup(0)
 
 - stack ends
 
  
- code segment para public 'CODE'
 
  
- ; divdw 函数
 
 - ; 入口参数:dx:ax 被除数
 
 - ;              cx 除数
 
 - ; 出口参数:dx:ax 商
 
 - ;              cx 余数          
 
  
- divdw proc near
 
 -         push bx
 
 -         mov bx,ax
 
 -         mov ax,dx
 
 -         xor dx,dx
 
 -         div cx
 
 -         push ax
 
 -         mov ax,bx
 
 -         div cx
 
 -         mov cx,dx
 
 -         pop dx
 
 -         pop bx
 
 -         ret
 
 - divdw endp
 
  
- ; dtoc 函数
 
 - ; 入口参数:   dx:ax : 目标数 
 
 - ;              ds:si : 字符串储存地址
 
 - ; 出口参数:   无
 
 - dtoc proc near
 
 -         push ax
 
 -         push cx
 
 -         push dx
 
 -         push si
 
 -         push di
 
 -         push si
 
 -         pop di
 
 - dtoc01: mov cx,10
 
 -         call divdw
 
 -         add cl,'0'
 
 -         mov byte ptr[di],cl
 
 -         inc di
 
 -         or dx,dx
 
 -         jnz dtoc01
 
 -         or ax,ax
 
 -         jnz dtoc01
 
 -         xor cl,cl
 
 -         mov byte ptr[di],cl
 
 -         dec di
 
 - dtoc02: mov al,[si]
 
 -         xchg [di],al
 
 -         mov [si],al
 
 -         inc si
 
 -         dec di
 
 -         cmp di,si
 
 -         ja dtoc02
 
 -         pop di
 
 -         pop si
 
 -         pop dx
 
 -         pop cx
 
 -         pop ax
 
 -         ret
 
 - dtoc endp
 
  
- ; show_str 函数
 
 - ; 入口参数     dh : 行号
 
 - ;              dl : 列号
 
 - ;              cl : 颜色
 
 - ;           ds:si : 字符串首地址,以字符 0 结束 
 
 - ; 出口参数     无
 
 - show_str proc near
 
 -         push ax
 
 -         push dx
 
 -         push si
 
 -         push di
 
 -         push es
 
 -         mov ax,0b800h
 
 -         mov es,ax
 
 -         mov al,160
 
 -         mul dh
 
 -         mov di,ax
 
 -         mov al,dl
 
 -         shl al,1
 
 -         cbw
 
 -         add di,ax
 
 -         cld
 
 - show0:  lodsb
 
 -         or al,al
 
 -         jz show1
 
 -         stosb
 
 -         mov al,cl
 
 -         stosb
 
 -         jmp show0
 
 - show1:  pop es
 
 -         pop di
 
 -         pop si
 
 -         pop dx
 
 -         pop ax
 
 -         ret
 
 - show_str endp
 
  
- ; cls 函数
 
 - ; 入口参数: 无
 
 - ; 出口参数: 无
 
  
- cls proc near
 
 -         push ax
 
 -         push bx
 
 -         push cx
 
 -         push dx
 
 -         mov ax,0600h
 
 -         mov bl,07h      
 
 -         xor cx,cx       ; 左上角
 
 -         mov dx,184fh    ; 右下角
 
 -         int 10h
 
 -         pop dx
 
 -         pop cx
 
 -         pop bx
 
 -         pop ax
 
 -         ret
 
 - cls endp
 
  
- pause proc near
 
 -         push ax
 
 -         xor ax,ax
 
 -         int 16h
 
 -         pop ax
 
 -         ret
 
 - pause endp
 
  
- work proc near
 
 -         push ax
 
 -         push bx
 
 -         push cx
 
 -         push dx
 
 -         push si
 
 -         push di
 
 -         push ds
 
 -         push es
 
 -         mov ax,data
 
 -         mov ds,ax
 
 -         mov ax,table
 
 -         mov es,ax
 
 -         xor di,di
 
 -         mov bp,0208h
 
 -         mov bx,8*21
 
 -         mov cx,21
 
 -         cld
 
 - work01: push cx
 
 -         xor si,si
 
 -         mov ax,es:[di]
 
 -         mov dx,es:[di+2]
 
 -         mov [si],ax
 
 -         mov [si+2],dx
 
 -         xor al,al
 
 -         mov [si+4],al
 
 -         mov ax,es:[di+4*21]
 
 -         mov dx,es:[di+4*21+2]
 
 -         push ax
 
 -         push dx
 
 -         add si,10h
 
 -         call dtoc
 
 -         xor dx,dx
 
 -         mov ax,es:[bx]
 
 -         add si,10h
 
 -         call dtoc
 
 -         mov cx,ax
 
 -         pop dx
 
 -         pop ax
 
 -         call divdw
 
 -         add si,10h
 
 -         call dtoc
 
 -         xor si,si
 
 -         mov dx,bp
 
 -         mov cl,07
 
 -         call show_str
 
 -         add si,10h
 
 -         add dx,16
 
 -         call show_str
 
 -         add si,10h
 
 -         add dx,16
 
 -         call show_str
 
 -         add si,10h
 
 -         add dx,16
 
 -         call show_str
 
 -         add bp,100h
 
 -         add di,4
 
 -         add bx,2
 
 -         pop cx
 
 -         loop work01
 
 -         pop es
 
 -         pop ds
 
 -         pop di
 
 -         pop si
 
 -         pop dx
 
 -         pop cx
 
 -         pop bx
 
 -         pop ax
 
 -         ret
 
 - work endp
 
  
- main proc far
 
 -         call cls
 
 -         call work
 
 -         call pause
 
 -         call cls
 
 -         mov ax,4c00h
 
 -         int 21h
 
 - main endp
 
 - code ends
 
 - end main
 
  复制代码 |   
 
 
 
 |