第10章课程设计1

assume cs:codesg


data segment


     db '1975','1976','1977','1978','1979'
     db '1980','1981','1982','1983','1984'
     db '1985','1986','1987','1988','1989'
     db '1990','1991','1992','1993','1994'
     db '1995'


     dd 16,22,382,1356,2390,8000,16000,24486,50065
     dd 97479,140417,197514,345980,590827,803530
     dd 1183000,1843000,2759000,3753000,4649000,5937000


     dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258
     dw 2793,4037,5635,8226,11542,14430,15257,17800


data ends


table segment


     db 21 dup ('year summ ne ?? ')


table ends


show segment                       //作为每显示一行数据的缓冲区,共64个字节,最后一个字节是0,这样才能用show_str函数显示,每显示一行后需要此64个字节重新初始化


     db 63 dup (32)
     db 0


show ends




codesg segment
     start:
         call mycal                                //调用函数将数据写入指定内存区域,并完成相应的运算
         call myshow                           //调用函数将内存区域中的数据按照指定格式显示到屏幕上,myshow函数又分别调用了其他几个函数
mov ax , 4c00h
         int 21h


     myshow:


          mov cx , 21
          mov ax , show
 mov ds , ax
 mov ax , table
 mov es , ax
 mov bx , 0


 zheli:
 mov si , 0
 mov ax , es:[bx]
 mov [si] , ax 
 add bx , 2
 add si , 2
 mov ax , es:[bx]
 mov [si] , ax
          add si , 14
 add bx , 3
 mov ax , es:[bx]
 add bx , 2
 mov dx , es:[bx]
 call dtoc
 add bx , 3
 add si , 16
 mov dx , 0
 mov ax , es:[bx]
 call dtoc
 add bx , 3
 add si , 16
 mov dx , 0
 mov ax , es:[bx]
 add bx , 3
 call dtoc
          add si , 15
 mov byte ptr [si] , 0

mov dl, 3
        mov dh, 25
        sub dh, cl
push cx
        mov cl, 2 
        mov si, 0
 call show_str
          call cleardata
 pop cx
 loop zheli


 ret


 cleardata:
           push ax
  push ds
  push bx
  push cx


 mov ax , show
 mov ds , ax
 mov bx , 0
 mov cx , 63
 clear:
          mov byte ptr [bx] , 32
 inc bx
          loop clear


 pop cx
 pop bx
 pop ds
 pop ax
 ret 


     mycal:
         mov ax,data
         mov ds,ax
         mov bx,0
         mov si,84
         mov bp,168
         mov cx,21
         mov ax,table
         mov es,ax
         mov di,0
         s:
         push cx
         mov cx,4


         t:
         mov al,[bx]
         mov es:[di],al
         inc bx
         inc di
         loop t


         mov byte ptr es:[di] , ' '
         inc di
         mov cx , 4


         f:
         mov al, [si]
         mov es:[di],al
         inc si
         inc di
         loop f


         mov byte ptr es:[di] , ' '
         inc di
         mov cx , 2


         g:
         mov al,ds:[bp]
         mov es:[di],al
         inc bp
         inc di
         loop g


         mov byte ptr es:[di] , ' '
         inc di


         mov ax , [si-4]
         mov dx , [si-2]
         div word ptr ds:[bp-2]
         mov es:[di],ax
         inc di
         inc di


         mov byte ptr es:[di] , ' '
         inc di


         pop cx
         loop s
         ret 


 dtoc:
 push cx
          push si
          push bx
          mov bx , 0
          push bx
          cal:
          mov cx , 0AH
          call divdw
 add cx , 30H
          push cx
          jmp short testax
    
          testax:
          mov cx , ax
          jcxz  testdx
          jmp short cal


          testdx:
          mov cx , dx
          jcxz ook
          jmp short cal


          ook:
          pop cx
          jcxz over
          mov [si] , cl
          inc si
          jmp short ook


          over:
          pop bx
 pop si
 pop cx
          ret


     show_str:
         push cx
         push bx
         push ax
         push es


         
         mov ax, 0B800h
         mov bx, 0
         mov es, ax
         sub ax, ax
         mov al, 0A0h
         mul dh
         add bx, ax
         sub ax, ax
         mov al, 2
mul dl
         add bx, ax
         mov al, cl
         
         sss:
         mov ch, 0
         mov cl, [si]
         jcxz ok
         mov es:[bx] , cl
         inc bx
         mov es:[bx] , al
         inc bx
         inc si
         jmp short sss


         ok:
         pop es
         pop ax
         pop bx
         pop cx
         ret




       divdw:
       push bx
       push si


       mov bx , ax
       mov ax , dx
       sub dx , dx
       div cx
       mov si , ax
       mov ax , bx
       div cx
       mov cx , dx
       mov dx , si


       pop si
       pop bx
       ret 
        


codesg ends
end start


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值