⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock.asm

📁 该文件是用MASM开发的
💻 ASM
字号:



;PROGRAM TITLE GOSE HERE--COMPARE STRING
datarea     segment
temp1       dw  ?
temp2       dw  ?
buffer0     db  ?
led1        db  ?
led2        db  ?
led3        db  ?
led4        db  ?
led5        db  ?
led6        db  ?
led7        db  ?
led8        db  ?
led9        db  ?
led10       db  ?
led11       db  ?
led13       db  ?
led14       db  ?
led15       db  ?
led16       db  ?
led17       db  ?
led18       db  ?
led19       db  ?
led20       db  ?
led21       db  ?
led22       db  ?
R0          db  ?
slogan      db  13                        ;move slogan
            db  50h,13,0,0                ;P
            db  65h,13,0,1                ;e
            db  72h,13,0,1                ;r
            db  73h,13,0,1                ;s
            db  6fh,13,0,1                ;o
            db  6eh,13,0,1                ;n
            db  61h,13,0,1                ;a
            db  6ch,13,0,1                ;l
            db  43h,13,0,2                ;C
            db  6ch,13,0,1                ;l
            db  6fh,13,0,1                ;o
            db  63h,13,0,1                ;c
            db  6bh,13,0,1                ;k
char_cnt    dw  ?
pointer     dw  ?
line_on     db  ?
col_on      db  ?
date        db  10  dup(?)
time        db  10  dup(?)
message1    db  'Personal Clock'
message2    db  'Do you want to quit(y/n)?'
message3    db  'Disigner:OwenChan' 
message4    db  'Instrutor:Li you xin'   
message5    db  '@2004Information Faculty of GuangDong University of Technonlgy.'
message6    db  'All rights reserved.'
;
datarea     ends
;------------------------------------------------------------------------------
video  segment at 0b800h   ;define extra segment
wd_buff    label word
v_buff     db 25*80*2 dup(?)
video      ends
;------------------------------------------------------------------------------
program   segment
;
main  proc far
          assume cs:program,ds:datarea,es:video
START:
          mov ax,datarea
          mov ds,ax
          mov ax,video
          mov es,ax
;-------------------------------------------------------------------------------
;the following programm is to set screen background
          mov   temp1,0000h
          mov   temp2,184fh
          call  clr_screen                 ;clear the screen
          lea   di,slogan                  ;DI points to slogan
                                                
          mov   dh,10                      ;starting is on 
          mov   dl,0                       ;line 10& col 0
          call  move_shape                 ;move the slogan
      
          mov   temp1,0000h
          mov   temp2,184fh
          mov   bh,087h                    ;set background color
          call  clr_screen
      
          mov   temp1,0a21h                ;set data background
          mov   temp2,0c2fh    
          mov   bh,5fh
          call  clr_screen

          mov   temp1,0f21h                ;set time background
          mov   temp2,112fh
          mov   bh,1eh
          call  clr_screen

          mov   temp1,0521h                ;set message1 background
          mov   temp2,072fh
          mov   bh,21h
          call  clr_screen
;-------------------------------------------------------------------------------
;
bigloop:
          mov   ah,1                       ;judge if key was pressed
          int   16h
          jz    yes_key                    ;on key pressed,to yes_key
          mov   ah,0
          int   16h
          cmp   al,1bh                     ;test if it is "esc"
          jnz   yes_key                    ;no,to key_key
          jmp   exit                 
;-------------------------------------------------------------------------------
yes_key:  mov   ah,2ch                     ;read time CH=hour(binary)
          int   21H                        ;CL=minute(binary), DH=second(binary)
                                           ;DL=百分秒(binary)
;-------------------------------------------------------------------------------
          mov   al,ch		
          mov   ah,0		
          mov   bh,10		
          div   bh		
          add   al,30h		
          mov   led1,al	        
          add   ah,30h	
          mov   led2,ah         
         
          mov   al,cl		
          mov   ah,0		
          mov   bh,10		
          div   bh		
          add   al,30h		
          mov   led4,al	        
          add   ah,30h	
          mov   led5,ah
         
          mov   al,dh		
          mov   ah,0		
          mov   bh,10		
          div   bh		
          add   al,30h		
          mov   led7,al	        
          add   ah,30h	
          mov   led8,ah
         
          mov   al,dl		
          mov   ah,0		
          mov   bh,10		
          div   bh		
          add   al,30h		
          mov   led10,al	        
          add   ah,30h	
          mov   led11,ah

          mov   led3,3ah
          mov   led6,3ah
          mov   led9,3ah
;-------------------------------------------------------------------------------
          mov   ah,04h                     ;read date CH=century (BCD),
          int   1aH                        ;CL=year(BCD),DH=month,DL=day
;-------------------------------------------------------------------------------
          mov   temp1,cx
          mov   al,cl
          and   al,0f0h
          mov   cl,4
          ror   al,cl
          add   al,30h
          mov   led15,al
          mov   cx,temp1
          and   cl,0fh
          add   cl,30h
          mov   led16,cl
 
          mov   al,dh
          and   al,0f0h
          mov   cl,4
          ror   al,cl
          add   al,30h
          mov   led18,al
          and   dh,0fh
          add   dh,30h
          mov   led19,dh
 
          mov   al,dl
          and   al,0f0h
          mov   cl,4
          ror   al,cl
          add   al,30h
          mov   led21,al
          and   dl,0fh
          add   dl,30h
          mov   led22,dl

          mov   led13,32h
          mov   led14,30h
          mov   led17,2dh
          mov   led20,2dh
;-------------------------------------------------------------------------------
          mov   R0,11
          lea   bx,led1
          mov   cx,1023h
          mov   Buffer0,1eH
         
disp_time:
          mov   al,[bx]
          call  display
          inc   bx
          inc   cx
          dec   R0
          jnz   disp_time
;-------------------------------------------------------------------------------     
          mov   R0,10
          lea   bx,led13
          mov   cx,0b22h
          mov   Buffer0,5fH
disp_date:
         mov    al,[bx]
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_date
;-------------------------------------------------------------------------------
         mov    R0,14
         lea    bx,message1
         mov    cx,0621h
         mov    Buffer0,21h
disp_mess1:
         mov    al,[bx]
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_mess1
         
disp_stars:
         mov    ah,02
         mov    bh,0
         mov    dh,0
         mov    dl,0
         int    10h
         mov    ah,09
         mov    al,'*'
         mov    bh,0
         mov    bl,0dah
         mov    cx,50h
         int    10h
continue:
         jmp    bigloop
;-------------------------------------------------------------------------------
exit:  
         mov    temp1,0000h
         mov    temp2,184fh
         mov    bh,017h                    
         call   clr_screen
         
         mov    R0,25
         lea    bx,message2
         mov    cx,0e16h
         mov    Buffer0,017h

disp_mess2:
         mov    al,[bx]
         
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_mess2

get_key:
         mov    ah,1
         int    21h
         cmp    al,'y'
         jz     quit
         cmp    al,'n'
         jz     do_move
         jnz    get_key
do_move: 
         jmp    start
quit:            
         mov    temp1,0000h
         mov    temp2,184fh
         mov    bh,07h             
         call   clr_screen
         
         mov    R0,17
         lea    bx,message3
         mov    cx,0621h
         mov    Buffer0,07h
disp_mess3:
         mov    al,[bx]
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_mess3
         
         call   delay
         mov    R0,20
         lea    bx,message4
         mov    cx,0a20h
         mov    Buffer0,07h
disp_mess4:
         mov    al,[bx]
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_mess4
         
         call   delay
       
         mov    R0,62
         lea    bx,message5
         mov    cx,0f08h
         mov    Buffer0,07h
disp_mess5:
         mov    al,[bx]
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_mess5        
         
         call   delay
       
       
         mov    R0,20
         lea    bx,message6
         mov    cx,1321h
         mov    Buffer0,07h
disp_mess6:
         mov    al,[bx]
         call   display
         inc    bx
         inc    cx
         dec    R0
         jnz    disp_mess6  
 
         mov    ah,4ch                     ;return to DOS
         int    21h
main     endp
;*******************************************************************************
;Bellow is a some  proc near
delay proc  near
         mov    cx,9999
         mov    temp1,9999
delay1:
         nop
         dec   temp1
         jnz   delay1
         loop  delay1
         ret 
delay    endp
;-------------------------------------------------------------------------------
;row=ch
;column=cl
;display symbol=al

display  proc  near
         push  bx
         push  cx
         push  ax
         mov   al,160
         mul   ch                          ;row*80*2+column*2
         mov   bl,cl
         rol   bl,1                         
         mov   bh,0                        ;bl*2
         add   bx,ax
         pop   ax
         mov   ah,Buffer0
         mov   es:[wd_buff+bx],ax
         pop   cx
         pop   bx
         ret 
display  endp
;-------------------------------------------------------------------------------
clr_screen  proc  near
         mov   ah,06h          
         mov   cx,temp1                    ;top=row*col
         mov   dx,temp2                    ;botten=row*col
         int   10h
         mov   ah,02h
         mov   dh,24
         mov   dl,80
         mov   bh,0
         int   10h
         ret
clr_screen     endp
;---------------------------------------
 move_shape proc near
         push  ax
         push  bx
         push  cx
         push  dx
         push  di
         mov   ah,0fh                      ;save BH to active page
         int   10h
         sub   ch,ch                       ;clear high byte of count
         mov   cl,[di]                     ;CL holds char count
         inc   di                          ;DI points to first char
           
         mov   char_cnt,cx                 ;save character count
         mov   pointer,di                  ;shape table pointer
         mov   line_on,dh                  ; and coordinates
         mov   col_on,dl                
;-------------------------------------------------------------------------------
;These instructions plot the shape on the screen
plot_next:
         add   dh,[di+2]                   ;update row pointer
         add   dl,[di+3]                   ; and cloumn pointer
         cmp   dl,80                       ;Is this char off the screen?
         jb    mov_crsr                     
         call  erase                       ;If so,erase shape and exit
         pop   di
         pop   dx
         pop   cx
         pop   bx
         pop   ax
         ret
mov_crsr:
         mov   ah,2                        ;move cursor
         int   10h
         mov   al,[di]                      ;fetch char value
         mov   bl,[di+1]                    ;and attribute
         push  cx
         mov   cx,1
         mov   ah,09
         int   10h                         ;write char to screen
         pop   cx
         add   di,4                        ;DI points to next char
         loop  plot_next                    
         call  dly_qrtr                    ;wait a quarter second
         call  erase                       ;then erase the shape
         jmp   short plot_next              
move_shape    endp
;-------------------------------------------------------------------------------
;This procedure earase a shape by reploting it
;  with attribute=0
erase  proc near
         mov   cx,char_cnt                 ;reload char count
         mov   di,pointer                  ;shape table pointer
         mov   dh,line_on                  ;line number
         mov   dl,col_on                   ;and column number
erase_next:
         add   dh,[di+2]
         add   dl,[di+3]          
         mov   ah,2
         int   10h
         mov   al,[di]                     ;to erase a character
         mov   bl,0                        ;use an attr=0
         push  cx
         mov   cx,1
         mov   ah,9
         int   10h
         pop   cx
         add   di,4
         loop  erase_next
         mov   cx,char_cnt                  ;reload char count
         mov   di,pointer                   ;shape table point
         mov   dh,line_on                   ;line number
         inc   col_on                       ;point to next column
         mov   dl,col_on
         ret                                ;return to caller
erase    endp
;-------------------------------------------------------------------------------
;This procedure generate a one_quarter second delay
dly_qrtr  proc  near
         push  cx
         push  dx
         mov   dx,5000
dl1:     mov   cx,1900
dl2:     loop  dl2
         dec   dx
         jnz   dl1
         pop   dx
         pop   cx
         ret
dly_qrtr endp
;-------------------------------------------------------------------------------
PROGRAM  ENDS
         END   START
      
                 
           

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -