《電子技術應用》
您所在的位置:首頁 > 嵌入式技術 > 解決方案 > 匯編源代碼之GET TIME OF DAY(獲取時間)

匯編源代碼之GET TIME OF DAY(獲取時間)

2017-07-23
關鍵詞: 匯編語言

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


本站內容除特別聲明的原創文章之外,轉載內容只為傳遞更多信息,并不代表本網站贊同其觀點。轉載的所有的文章、圖片、音/視頻文件等資料的版權歸版權所有權人所有。本站采用的非本站原創文章及圖片等內容無法一一聯系確認版權者。如涉及作品內容、版權和其它問題,請及時通過電子郵件或電話通知我們,以便迅速采取適當措施,避免給雙方造成不必要的經濟損失。聯系電話:010-82306118;郵箱:aet@chinaaet.com。
主站蜘蛛池模板: 国产精品综合色区在线观看| 欧美黑人性暴力猛交喷水| 在线免费观看你懂的| 久久久久亚洲精品男人的天堂 | 菠萝蜜视频在线观看| 国产精品美女久久久久久2018| 两个人www免费高清视频| 最近中文AV字幕在线中文| 做暧暧免费小视频| 色噜噜狠狠狠狠色综合久一| 国产精品久久久久…| CAOPORN视频在线观看| 手机av在线播放| 久久精品视频大全| 欧美精品偷自拍另类在线观看| 午夜免费福利影院| 久久久久久久性| 国产色无码精品视频国产| 中文字幕乱码人在线视频1区| 日韩精品无码专区免费播放| 亚洲欧洲在线观看| 综合图区亚洲欧美另类图片 | 中文精品北条麻妃中文| 欧美亚洲国产精品久久久久 | 亚洲国产精品热久久| 男女猛烈无遮掩免费视频| 国产00粉嫩馒头一线天萌白酱| 91手机在线视频观看| 国语自产少妇精品视频蜜桃| 一区二区视频网| 护士强迫我闻她的臭丝袜脚| 久久精品国产99国产精品| 欧美午夜成年片在线观看| 免费乱理伦片在线直播| 美女大量吞精在线观看456| 国产区精品在线| 在线视频你懂的国产福利| 大桥未久aⅴ一区二区| 一区二区三区视频在线播放| 故意打开双腿让翁公看| 久久国产精品99国产精|