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

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

2017-07-23
關(guān)鍵詞: 匯編語言

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


本站內(nèi)容除特別聲明的原創(chuàng)文章之外,轉(zhuǎn)載內(nèi)容只為傳遞更多信息,并不代表本網(wǎng)站贊同其觀點。轉(zhuǎn)載的所有的文章、圖片、音/視頻文件等資料的版權(quán)歸版權(quán)所有權(quán)人所有。本站采用的非本站原創(chuàng)文章及圖片等內(nèi)容無法一一聯(lián)系確認版權(quán)者。如涉及作品內(nèi)容、版權(quán)和其它問題,請及時通過電子郵件或電話通知我們,以便迅速采取適當措施,避免給雙方造成不必要的經(jīng)濟損失。聯(lián)系電話:010-82306118;郵箱:aet@chinaaet.com。
主站蜘蛛池模板: 精品久久久久久亚洲精品| 97视频久久久| 蜜桃麻豆WWW久久囤产精品| 在线观看特色大片免费网站| 久久精品无码一区二区三区| 老师办公室被吃奶好爽在线观看| 成人午夜一区二区三区视频 | 春色www在线视频观看| 国产三级在线观看视频不卡| 一级做性色a爰片久久毛片| 朋友把我玩成喷泉状| 亚洲香蕉免费有线视频| 色噜噜狠狠成人中文综合| 国产男女猛烈无遮挡免费视频网站| caopon在线| 欧美一区二区三区视频在线观看| 免费看欧美一级特黄a大片| 2021国产精品自产拍在线观看| 日韩中文在线播放| 兴奋的阅读td全集视频| 香蕉视频在线观看网站| 娇妻当着我的面被4p经历| 久久精品国产99国产精品澳门| 欧美肥老太肥506070| 免费黄色a视频| 无遮挡1000部拍拍拍免费凤凰| 日本三级在线观看免费| 亚洲国产欧美日韩精品小说| 看看镜子里我怎么玩你| 国产欧美日韩综合| 999精品在线| 巨胸动漫美女被爆羞羞视频| 亚洲国产精品一区二区第四页 | 中文字幕免费看| 日韩精品在线一区二区| 冠希与阿娇实干13分钟视频| 高校饥渴男女教室野战| 国产精品久久久久久亚洲小说| 中文在线天堂网| 日韩伦理一区二区| 人人妻人人澡人人爽欧美精品|