庞大资源库的计算机教程网站!
设为首页
加入收藏
总编信箱
投稿或申请专栏请先 [登 陆]
首页 操作系统 程序设计 图形图像 媒体动画 机械电子 WEB开发 数 据 库 办公系列 路由技术 网络原理 网络应用
认证考试 安全技术
首页>程序设计>汇编语言>相关源码>正文
资料搜索
Google搜索
Google
返回上级列表

推荐文章

快速保存网页中所有图片的方法
Windows中让光驱巧妙“隐身”技
防范非法用户入侵Win 2000/XP系
两款比较典型的ASP木马防范方法
有关表格边框的css语法整理
Windows XP中可以被禁用的服务
SQL Server导出导入数据方法
Javascript所有对象的属性的获
网页(HTML)中的特殊字符
与篮球共舞,尽显模式本色
QQ病毒的手工清除方法
Photoshop为极品美女打造性感睫
天衣无缝:IIS与PHP水火也相容
SQL Server存储过程编写和优化

GET TIME OF DAY(获取时间)

 作者:本站收集   日期:2005-8-1 15:38:50
字号选择〖 〗/ 双击滚屏 单击停止   

INTRODUCTION

The first example is of a program that uses the system time of day. This example uses a conditional assembly to decide between two ways to get the time of day. One way is to use the DOS time of day function; the other way, illustrated by the second code example, uses the BIOS time of day function. The second example can be used to replace the standard DOS call to get the time of day. This second example will return the time of day much faster than the standard DOS call.

FIRST EXAMPLE

This example runs until a set time of day occurs and then terminates. This code gets the time of day information from the DOS command line input data. If there is bad input data, then an error message is displayed, informing the user what the correct input data format is. While the program is waiting for the terminate time, it will scan the keyboard for an escape key to terminate the program on user demand.

; Wait for Time
;This program can be executed inside of a .BAT file to
;  stall execution of the .BAT file until a set time of day
;?????????????????????????????????????????????????????????? ???
;conditional assembly flag, 0 to use DOS, 1 to use BIOS example
.MODEL tiny
use_bios_flag EQU 1
;----------- stack area ---------------
.STACK 500
;--------------------------------------
.CODE
;*************  @@@@@@@@@@@@@@  ***************
start   proc    near
        mov     bx,80H        ;index command line data
        mov     al,[bx]       ;get size of string variable
        mov     ax,cs
        mov     ds,ax         ;reset data segment
        mov     psp_seg,es    ;save PSP address
        mov     es,ax         ;reset extra segment
        cmp     al,4          ;is there data in string
        jb      exit_bad      ;branch if no data
        inc     bx
        inc     bx            ;point to start of data
      ;get number out of buffer area
        call    get_number
        jc      exit_bad      ;branch if number bad
        mov     wait_hour,al  ;save number in hour
        cmp     al,23         ;?? number too large ??
        ja      exit_bad      ;branch is too large
      ;check the number terminating character
        cmp     ah,":"
        jne     exit_bad      ;branch if not :
      ;point to start of next number
        inc     bx
      ;get next number out of buffer area
        call    get_number
        jc      exit_bad      ;branch if number bad
        cmp     al,59         ;?? number too large ??
        ja      exit_bad      ;branch if too large
        mov     wait_minute,al     ;save number to minute
   ;display executing wait message
        mov     ah,9        ;set DOS function number
        lea     dx,wait_message
        int     21H         ;DOS call to display message
;________________________________
;**********  !!!!!!!!  **********
wait_loop:
      ;scan keyboard for keys
        mov     ah,1
        int     16H
        jz      wait_no_key     ;branch if no key
        mov     ah,0            ;if here then keyboard data
        int     16H             ;get key code from buffer
        cmp     ax,3B00H        ;check key code
        je      exit            ;branch if exit key
        cmp     al,1BH          ;check for ESC key
        je      exit            ;branch if ESC key
wait_no_key:
   ;find out what time it is
;conditional assembly ????????????????????
      ;use this code if linking to code in this section
IF use_bios_flag
        call    get_time_of_day
      ;else use this code if calling DOS for time
ELSE
        mov     ah,2CH
        int     21H             ;get current time of day
ENDIF
        cmp     ch,wait_hour
        jne     wait_loop       ;loop if not time
        cmp     cl,wait_minute
        jne     wait_loop       ;loop if not time
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
exit:
        mov     ah,4CH
        int     21h             ;terminate program
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
exit_bad:
        mov     ah,9
        lea     dx,exit_bad_message
        int     21H             ;DOS call to display message
        jmp     exit
;  ***** ^^^^^^^^ ***** ^^^^^^^^ ****
get_number:
 ;on entry BX indexes ASCII number data in PSP segment area
 ;on exit if carry clear,
  ; register AL has binary number, from 0 to 99
  ; BX indexes past the number,
  ; AH has exiting character code indexed by BX
     push ds
     mov  ds,psp_seg
     mov  al,[bx]
     inc  bx
     call number_check
     jc   get_number_bad
     mov  ah,al
     mov  al,[bx]
     call number_check
     jc   get_number_1
get_number_2a:
     cmp  ah,0
     je   get_number_2
     add  al,10
     dec  ah
     jmp  get_number_2a
get_number_2:
     inc  bx
     mov  ah,al
     mov  al,[bx]
get_number_1:
     cmp  al,":"
     je   get_number_1a
     cmp  al,0DH
     jne  get_number_bad
get_number_1a:
     xchg al,ah
     pop  ds
     clc       ;set good number flag
     ret
get_number_bad:
     pop  ds
     stc       ;set bad number flag
     ret
;#################################################
number_check:
   ;this code checks for ASCII number in AL
    ; if it finds a number, then it makes it binary
    ; and returns with carry clear, else carry set
     cmp  al,"0"
     jb   number_bad
     cmp  al,"9"
     ja   number_bad
     and  al,0FH
     clc
     ret     stc
     ret
;*************************
start     endp
;+++ this routine combines data and code into one segment +++
; define data area
psp_seg         dw      0
wait_hour       db      0
wait_minute     db      0

wait_message    db     0DH,0AH,0DH,0AH
        db   "Wait in progress, Press [ESC] to exit",0DH,0AH
                db      "$"
exit_bad_message        db      0DH,0AH
        db   "To use TimeWait program enter timeout data "
        db   "from command line as example:",0DH,0AH,0DH,0AH
        db     "TimeWait 11:30",0DH,0AH,0DH,0AH
        db     "Note, timeout hours vary from 0 to 23, "
        db     "and minutes from 0 to 59.",0DH,0AH
        db     "$"
;______________________________________
     end  start
上一篇:MAKE SOUNDS (发声)    下一篇:PRINT FILE PROGRAM (打印文件)  
[发送给好友]  [关闭窗口]  [返回顶部]   转载请注明来源:www.it00.com   
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
责任编辑: 原点 投稿作者: 本站收集
信息来源: 网络 录入时间: 2005-8-1 15:38:50
关于我们 - 广告服务 - 版权申明 - 网站地图 - 联系方式 - 总编信箱 - 会员投稿