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

📄 clock.asm

📁 一个数字时钟的汇编语言程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;-------------------------------------------------------------------------
;draw1.asm
;------------------------------------------------------------------------
extrn gensound:far
data segment
table1     dw  pr0
           dw  pr1
           dw  pr2
           dw  pr3
           dw  pr4
           dw  pr5
           dw  pr6
           dw  pr7
           dw  pr8
           dw  pr9
test_table db 14 dup(?)
temp       dw 10 dup(?)
temp1      dw ?
temp2      db 10 dup(?)
temp3      db 14 dup(?)
s_h_pos    dw ?
s_v_pos    dw ?
i          dw 1

con_flag   dw  0
con_flag1  dw  0

notice    db  'Real-Time Clock$ '
n1        db  'Main Menu: $'
n2        db  '1.Display current system time. [Press D]$'
n3        db  '2.Set current system time. [Press S]$'
n4        db  '3.Set alarm-clock time.[Press A]$'
n5        db  '4.Exit. [Press ESC]$'

notice1   db  'Please input the alarm time:$ '
msg1      db  '1.Input format: hhmmss eg: 123000 $'
msg2      db  '2.Back [Press B]  $'

notice2   db  'Please input the new time:$ '
set_mes1      db  '1.Input format: yyyymmddhhmmss eg: 20031026123000 $'
set_mes2      db  '2.Back [Press B]  $'

in_err    db  'Your input format would be wrong! [RR] $'
set_err       db  'setting fails! $'
step      equ 10
space     equ 15
key_ESC   equ  1bh
key_A     equ  41h
key_B     equ  42h
key_D     equ  44h
key_S     equ  53h
key_R     equ  52h
key_a1    equ  61h
key_b1    equ  62h
key_d1    equ  64h
key_s1    equ  73h  
key_r1    equ  72h
mus_freq  dw 330,294,262,294,3 dup(330)
          dw 3 dup(294),330,392,392
          dw 330,294,262,294,4 dup(330)
          dw 294,294,330,294,262,-1
mus_time  dw 6 dup(1000),2000
          dw 2 dup(1000,1000,2000)
          dw 12 dup(1000),4000
data ends

;--------------------------------------------------------------------------------------
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
;----------------------------------------------------------------------------------------
main proc near
main_menu:
          mov    ah,00h
          mov    al,03h
          int    10h
          
          mov    dl,25
          mov    dh,5
          mov    bh,0
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset notice
          int    21h
          mov    dl,10
          mov    dh,8
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset n1
          int    21h
          mov    dl,10
          mov    dh,10
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset n2
          int    21h
          mov    dl,10
          mov    dh,11
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset n3
          int    21h
          mov    dl,10
          mov    dh,12
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset n4
          int    21h
          mov    dl,10
          mov    dh,13
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset n5
          int    21h
check1:   call test_alarm
          mov    ah,7
          int    21h
          cmp    al,key_A
          jz     alarm_set
          cmp    al,key_a1
          jz     alarm_set          
          
          cmp    al,key_s1
          jz     set_time
          cmp    al,key_S
          jz     set_time
          
          cmp    al,key_D
          jz     display_time
          cmp    al,key_d1
          jz     display_time
          
          cmp    al,key_ESC
          jnz    check1
          
          mov	ah,00h
          mov	al,03h
          int	10h

          mov	ah,4ch
          int	21h

main endp
;--------------------------------------------------------------------------------------------
display_time:
         call display
alarm_set: 
         call alarm
set_time:
         call set
;-------------------------------------------------------------------------------------------
set proc near    
back_set:
          mov    ah,00h
          mov    al,03h
          int    10h       
          
          mov    dl,25
          mov    dh,5
          mov    bh,0
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset notice2
          int    21h
          mov    dl,10
          mov    dh,8
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset set_mes1
          int    21h
          mov    dl,10
          mov    dh,10
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset set_mes2
          int    21h             
          call   test_alarm
refresh1:  mov    si,0          
re_str1:  
          mov    ah,01h
          int    21h         
          cmp    al,0dh
          jz     confirm1
          
          cmp    al,'0'
          jb     cp_key1
          cmp    al,'9'
          ja     cp_key1
          sub    al,30h
          mov    temp3[si],al
          inc    si
          mov    con_flag1[0],si        
          jmp    re_str1
cp_key1:  
          cmp    al,key_r1
          jz     back_set
          cmp    al,key_R
          jz     back_set
          cmp    al,key_b1
          jz     main_back1
          cmp    al,key_B
          jz     main_back1
          jnz    confirm1
main_back1:jmp   main_menu    
    
confirm1: mov    cx,con_flag1[0]
          cmp    cx,14
          jz     check_b1
          mov    dl,10
          mov    dh,20
          mov    ah,2
          int    10h
          mov    ah,9
          mov    dx,offset in_err
          int    21h
                    
check_back1: mov    ah,7
          int    21h
          cmp    al,key_r1
          jz     refresh1
          cmp    al,key_R
          jz     refresh1
          jmp    check_back1
check_b1: call   cacul_time
   
          mov    ah,7
          int    21h
          cmp    al,'r'
          jz     main_back1
          cmp    al,key_B
          jnz    check_b1          
exit_set:   
          ret
set endp
;-------------------------------------------------------------------------------------------

cacul_time proc near

		mov		ax,1000
		mov		cl,temp3[0]          ;caculate year
		and		cx,0ffh
		mul		cx
		push	ax
		mov		al,100
		mov		cl,temp3[1]
		mul		cl
		push	ax
		mov		al,10
		mov		cl,temp3[2]
		mul		cl
		add		al,temp3[3]
		pop		cx
		add		ax,cx
		pop		cx
		add		ax,cx
		push	ax
;-------------------------
		mov		al,10
		mov		cl,temp3[4]
		mul		cl
		add		al,temp3[5]
		push	ax
;-------------------------
		mov		al,10
		mov		cl,temp3[6]
		mul		cl
		add		al,temp3[7]
		push	ax
;-------------------------
		mov		al,10
		mov		cl,temp3[8]
		mul		cl
		add		al,temp3[9]
		push	ax
;-------------------------
		mov		al,10
		mov		cl,temp3[10]
		mul		cl
		add		al,temp3[11]
		push	ax
;-------------------------
		mov		al,10
		mov		cl,temp3[12]
		mul		cl
		add		al,temp3[13]
		push	ax
;-------------------------
		pop		bx
		mov		dh,bl

		pop		bx
		mov		cl,bl

		pop		bx
		mov		ch,bl

		mov		ah,2dh
		int		21h
		cmp		al,0ffh
		je		error

		pop		 bx
		mov		dl,bl

		pop		bx
		mov		dh,bl

		pop		bx
		mov		cx,bx

		mov		ah,2bh
		int		21h
		cmp		al,0ffh
		je		error

		jmp		back_set
error :
		mov		dx,offset set_err
		mov		ah,9
		int		21h

		mov		ah,4ch
		int		21h	
cacul_time endp
;------------------------------------------------------------------------------------
display proc near

		mov		ax,0600h
		mov		 bh,07
		mov		cx,0
		mov		dx,148fh
		int		10h
		mov		ah,00h
		mov		al,11h
		int		10h
;-------------------

tt:		call	test_alarm
		mov    ah,0bh               
		int    21h
		cmp    al,0
		jnz    check2


		mov		bl,14
back:   mov		cx,33144
		call	waitf
		dec		bl
		jnz		back

		call	readtime
        mov 	 cx,100			
        mov 	 dx,100

line:
        mov 	 ah,0ch
        mov 	 al,0
        mov 	 bh,0
        int 	 10h
        inc 	 cx
        cmp 	 cx,400
        jnz 	 line
        mov 	 cx,100
        inc 	 dx
        cmp 	 dx,124
        jnz 	 line

		mov		 di,0
ll:
		mov		 al,test_table[di]
		mov		i,di
		inc		di

⌨️ 快捷键说明

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