寫一個 TSR 程式, 常駐你的工作程式, TSR 的程式其實是很簡單的, 以 TCC 或 BC 程式碼如下:
此 TSR 省略了很多安全呼叫的程序碼(例如DTA and PSP的保留及回復,及inDosFlag 和 CriticalFlag 的判斷, 及中斷程序的不可重覆進入限定) , 不過在此應該不會有影响
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <io.h>
#include <bios.h>
#include <fcntl.h>
static void interrupt (*OldInt8)(void);
static void interrupt NewInt8(WORD bp,WORD di,WORD si,WORD ds,WORD es,WORD dx,WORD cx,WORD bx,WORD ax);
static void interrupt NewInt8(WORD bp,WORD di,WORD si,WORD ds,WORD es,WORD dx,WORD cx,WORD bx,WORD ax)
{
    if(OldInt8!=NULL) OldInt8();
    
    // 你的判斷程序寫在這裡 ....
    // 1. 取得時間
    // 2. 時間到了嗎
    // 3. 執行關機
}
int main(int argc, char *argv)
{
    struct SREGS    sregs;
    union  REGS     regs;
    unsigned short  u16;
    // 本程式所需空間
    u16 = *(unsigned far*)MK_FP(_psp-1, 3) + 16;
    // 計時器中斷每秒會被呼叫 18.2 次
    OldInt8 =getvect(0x08);     // Store 0x08 VECTOR
    setvect(0x08,NewInt8);      // install new ISR
    
    keep(0, u16);               // 常駐在記憶體
    return(1);
}