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 Waiting for the Terminate Time, IT Will Scan The Keyboard for An escape key to terminate the program on user demad.
Wait for Time; this program can be el x; 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 TINYUSE_BIOS_FLAG EQU 1; -----------------------------. stack 500; ---- ----------------------------------. Code; ************ @@@@@@@@8************ Start Proc Nearmov BX, 80H; Index Command Line Datamov Al, [BX]; Get Size of String variablemov ax, csmov ds, ax; reset data segmentmov psp_seg, es; save PSP addressmov es, ax; reset extra segmentcmp al, 4; is there data in stringjb exit_bad; branch if no datainc bxinc bx; point to start of data; get number out of buffer areacall get_numberjc exit_bad; branch if number badmov wait_hour, al; save number in hourcmp al, 23; ?? number too large ?? ja exit_bad; branch is too large; check the number terminating charactercmp ah, ":" jne EXIT_BAD; Branch IF NOT: POINT to Start of Next Numberin c bx; get next number out of buffer areacall get_numberjc exit_bad; branch if number badcmp al, 59; ?? number too large ?? ja exit_bad; branch if too largemov wait_minute, al; save number to minute; display executing wait messagemov ah, 9; SET DOS FUNCTION NUMBERLEA DX, WAIT_MESSAGEINT 21H; DOS CALL TO Display Message; ________________________________; ********** !!!!!!!! ********* WAIT_LOOP :; scan keyboard for keysmov ah, 1int 16Hjz wait_no_key; branch if no keymov ah, 0; if here then keyboard dataint 16H; get key code from buffercmp ax, 3B00H; check key codeje exit; branch if exit keycmp al, 1BH; check for ESC Keyje exit; branch if esc keywait_no_key:; find out what time it is;
CONDITIONAL Assembly ????????????????????????????????????????????????????????????????????????????????????; Use this code if linking to code in this sectionif using_bios_flagcall get_time_of_day; else Useelsemov AH, 2CHINT 21H; Get current time of dayndifcmp ch, wait_Hourjne Wait_loop; loop if not time; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ exit: mov ah, 4CHint 21h; terminate program; !!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!! EXIT_BAD: MOV AH, 9LEA DX, EXIT_BAD_MESSAGEINT 21H; DOS CALL TO Display Messagejmp 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 BXpush dsmov ds, psp_segmov al, [bx] inc bxcall number_checkjc get_number_badmov ah, almov al, [bx] call number_checkjc get_number_1get_number_2a: cmp ah, 0je get_number_2add al, 10dec ahjmp get_number_2aget_number_2: inc bxmov ah, almov al, [ bx] GE t_number_1: cmp al, ":" je get_number_1acmp al, 0DHjne get_number_badget_number_1a: xchg al, ahpop dsclc; set good number flagretget_number_bad: pop dsstc; set bad number flagret; ################ ########################## Number_Check:; this code checks for ascii number in al; if it Finds a Number , "9" JB Number_Badcmp Al, "9" JB Number_Badcmp Al, "9" JA Number_Badcmp Al, 0FHClcret Stcret; ************** ********** Start Endp; this Routine Combines Data And Code Into One Segment ; define data isapsp_seg dw 0wait_HOUR DB 0WAIT_MINUTE DB 0