With Windows 1ch, users can interrupt their own clock and Run DOS programs normally.

Source: Internet
Author: User

Program purpose: use Windows 1ch to provide users with the ability to interrupt their own clock and Run DOS programs normally *

Program Author: Wang dingqiao, class 0801, Computer Science and Technology College, Hubei Normal University *
Core algorithms: extract and save the original interruption, create a new middle-segment read time, and resident the memory, and then exit and execute the original and new middle-segment display time in sequence to return the Middle-segment *
; Production time *
; Program copyright: the code is publicly available for learning and communication, but cannot be referenced in all. To use it, Please carefully understand it before making it by yourself *
Additional instructions: This program is an experiment in the operating system experiment *
Main reference: IBM-PC assembly language programming Huaihai Institute of Technology Liu jingliang microcomputer principle and interface technology system residence time Design **
; **************************************** **************************************** **************************

Codesg segment; the program only describes assume DS: codesg, CS: codesgmain proc far start: push ds sub ax, ax push ax mov ax, codesg mov ds, ax; ------------------------------- take the original interrupt vector of 1ch and save mov Al, 1ch mov ah, 35 h int 21 h mov oldint, BX mov BX, es mov oldint + 2, BX; ------------------------------- reset 1ch interrupt vector mov dx, offset updtime mov ax, SEG updtime mov ds, ax mov Al, 1ch mov ah, 25 h int 21 h ;--------------------------------- Take the current time and save mov ah, 2ch int 21 h mov hour, CH mov min, CL mov sec, DH; --------------------------------- the program resident memory and exit mov ah, 31 H mov Al, 0 mov dx, (prog_len + 15)/16) + 16; calculates the resident byte int 21 h main endp; ---------------------------------------------------- the new part of updtime proc near; --------------------------------- first execute the original interrupted content pushf call dword ptr Cs: oldint; ------------------------------- start executing the newly added content push ax ;---------- Protection Register push BX push CX push DX; ----------------------------------- use the DS register to specify the address of the stored data mov ax, codesg mov ds, ax; --------------------------------- display of processing time and count jnz exit of the incoming part; do not include carry in the second before the time, continue to interrupt add sec, 1; ---------- processing second CMP sec, 60 jnz docnt; if the period does not reach one minute, no carry is required. mov sec, 0 add min, 1; ---------- CMP min, 60 jnz docnt are interrupted. If the period does not reach one hour, no carry is required. mov Min is interrupted, 0 add hour, 1; ---------- CMP hour, 24 jnz docnt during processing; do not carry until 24, continue Interrupt mov hour, 0 docnt: mov count, 18; reset the counter call timeshow when the time reaches one second; update the time only when the 1 second arrives, and do not update exit when the time is not reached :; -------------------------- return interrupted pop DX; ---------- recovery register pop CX pop BX pop ax iretupdtime endp; effectimeshow proc near; --------------- display on the screen based on time; cursor reads the current cursor position and stores xor bh, BH mov ah, 03 h int 10 h mov cur, DX ;------------------------------- -- Set the cursor to the appropriate position xor bh, BH mov DH, 0 mov DL, 71 mov ah, 02 int 10 h; --------------------------------- display hour sub BX, BX mov BL, hour call bindec; call two-digit decimal digit display subroutine call semi; call semicolon display subroutine; ------------------------------- minute sub BX, BX mov BL, Min call bindec call semi; ------------------------------- display Second sub BX, BX mov BL, SEC call bindec; --------------------------------- restore cursor xor bh, BH mov dx, cur mov ah, 02 h int 10 h re T timeshow endp; then display the two-digit decimal number bindec proc near mov CX, 10 call dec_div; calculate 10 calls curmove mov CX, 1 call dec_div before converting the two-digit decimal number; call curmove retbindec endp when converting a two-digit decimal number, and convert the two-digit decimal number to the one-digit decimal number to display dec_div proc near mov ax, BX mov dx, 0 Div CX; divide mov BX according to the content in CX, DX push BX add Al, 30 h; display the sizes of suppliers xor bh, BH MoV BL, 41 h mov ah, 09 h mov CX, 1 int 10 h pop BX; retain the remainder so that a single digit retdec_div endp can be calculated next time; returns the semicolon semi proc near mov Al, ':' xor bh, BH mov BL, 41 h mov ah, 09 h mov CX, 1 int 10 h call curmove RET semi endp; ------------------------------------------------------ move the cursor curmove proc near mov ah, 03 int 10 h Inc DL mov ah, 02 int 10 h retcurmove endp ;------------ ------------------------------------------ The data to be saved and used; ------------ save the old vector oldint DW 2 DUP (?); ------------ Timing parameter count DW 18 hour db 0 min db 0 sec db 0; ------------ cursor parameter cur DW 0; ---------------- prog_len equ $-Main codesg endsend start

**************************************** **************************************** ***************

Running effect:


The corresponding program: http://download.csdn.net/detail/ziyuanxiazai123/2791641

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.