home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / PCTJOS2.ZIP / ASKSYS.ASM next >
Assembly Source File  |  1988-09-16  |  4KB  |  111 lines

  1. ; ASKSYS.ASM - Implements dual-boot w/timeout for DOS & OS/2
  2. ;
  3. ; Copyright (C) 1988 Ziff Communications Co. and PC Tech Journal
  4. ; Written by Ted Mirecki
  5. ;
  6. ; Set default system by value of label DEFAULT
  7. ; Set timeout interval by value of label SECONDS
  8.  
  9. OS2        equ     13             ;Enter key starts OS/2
  10. DOS        equ     27             ;Esc key starts DOS
  11. DEFAULT    equ     DOS            ;If neither key pressed
  12. SECONDS    equ     15             ;Timeout interval
  13.  
  14. group1     group   code,data
  15.            assume  cs:group1, ds:group1
  16.  
  17. code       segment byte public    ;establish code segment first
  18. code       ends
  19.  
  20. data       segment word           ;but define data seg first
  21. time       dw      SECONDS*18
  22. oldint8    label   dword
  23. int8off    dw      0
  24. int8seg    dw      0
  25. bootaddr   dd      7C00h          ;0000:7C00h
  26. msg$       db      "OS/2 - DOS Dual Boot feature", 0Dh, 0Ah
  27.            db      "Copyright (C) 1988 Ziff Communications Co. "
  28.            db      "and PC Tech Journal", 0Dh, 0Ah, 0Ah
  29.            db      "Boot: Enter = OS/2, Esc = DOS", 0Dh, 0Ah, 7, 0
  30.            even
  31. dosboot    db      'QQQQ'         ;marker for patching in boot rec
  32.            db      508 dup (0)    ;space for rest of boot rec
  33. os2boot    db      512 dup (0)    ;space for other bootrec
  34. data       ends
  35.  
  36. code       segment byte public    ;resume same code segment
  37. asksys     proc
  38.            push    ax
  39.            push    bx
  40.            push    cx
  41.            push    si
  42.            push    di
  43.            push    ds
  44.            push    es
  45.            mov     ax,cs          ;set ds to code segment
  46.            mov     ds,ax
  47.            lea     si,msg$        ;get address of message
  48. boot1:     lodsb
  49.            or      al,al          ;null byte = end of message
  50.            jz      boot2
  51.            mov     ah,0Eh         ;write TTY function
  52.            int     10h            ;BIOS video call
  53.            jmp     boot1          ;loop til end of message
  54.            int8 = 8*4             ;address of int 8 vector
  55. boot2:     xor     ax,ax
  56.            mov     es,ax          ;ES --> interrupt table
  57.            mov     ax,es:int8     ;get int 8 address
  58.            mov     bx,es:int8+2
  59.            mov     int8off,ax     ;save it
  60.            mov     int8seg,bx
  61.            lea     bx,timertick   ;address of timer routine
  62.            cli                    ;hold off interrupts
  63.            mov     es:int8,bx     ;set timer interrupt
  64.            mov     es:int8+2,cs
  65.            sti                    ;allow interrupts
  66. boot3:     mov     ah,1           ;get keyboard status
  67.            int     16h
  68.            jnz     boot4          ;key pressed if no zero flag
  69.            cmp     time,0         ;else test for timeout
  70.            jg      boot3          ;no timeout: test kb again
  71.            mov     al,DEFAULT     ;set default keystroke
  72.            jmp     short boot5    ;go process it
  73. boot4:     xor     ah,ah          ;get the keystroke
  74.            int     16h
  75.            cmp     al,27          ;is it escape?
  76.            je      boot5
  77.            cmp     al,13          ;is it return?
  78.            jne     boot3          ;if neither, read kb again
  79. boot5:     mov     bx,int8off     ;get original int 8 vector
  80.            mov     cx,int8seg
  81.            cli
  82.            mov     es:int8,bx     ;restore it in vector table
  83.            mov     es:int8+2,cx
  84.            sti
  85.            lea     si,dosboot     ;load DOS boot record address
  86.            cmp     al,27          ;escape = DOS
  87.            je      boot6
  88.            lea     si,os2boot     ;else load OS2 boot rec address
  89. boot6:     les     di,bootaddr    ;ES:DI --> load addr for boot rec
  90.            mov     cx,256         ;length of boot rec in words
  91.            rep     movsw          ;insert boot rec at boot address
  92.            pop     es             ;exit sequence
  93.            pop     ds
  94.            pop     di
  95.            pop     si
  96.            pop     cx
  97.            pop     bx
  98.            pop     ax
  99.            jmp     cs:bootaddr    ;branch to boot record
  100. asksys     endp
  101.  
  102. ; Int 8, timer tick hardware interrupt, is repointed here.
  103. ; This routine counts down a time value and chains to original INT 8.
  104.  
  105. timertick  proc
  106.            dec     cs:time
  107.            jmp     cs:oldint8
  108. timertick  endp
  109. code       ends
  110.            end
  111.