home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / os2dualb / asksys2.asm < prev    next >
Assembly Source File  |  1988-12-29  |  4KB  |  112 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. boot2:
  55. int8       =       8*4            ;address of int 8 vector
  56.            xor     ax,ax
  57.            mov     es,ax          ;ES --> interrupt table
  58.            mov     ax,es:int8     ;get int 8 address
  59.            mov     bx,es:int8+2
  60.            mov     int8off,ax     ;save it
  61.            mov     int8seg,bx
  62.            lea     bx,timertick   ;address of timer routine
  63.            cli                    ;hold off interrupts
  64.            mov     es:int8,bx     ;set timer interrupt
  65.            mov     es:int8+2,cs
  66.            sti                    ;allow interrupts
  67. boot3:     mov     ah,1           ;get keyboard status
  68.            int     16h
  69.            jnz     boot4          ;key pressed if no zero flag
  70.            cmp     time,0         ;else test for timeout
  71.            jg      boot3          ;no timeout: test kb again
  72.            mov     al,DEFAULT     ;set default keystroke
  73.            jmp     short boot5    ;go process it
  74. boot4:     xor     ah,ah          ;get the keystroke
  75.            int     16h
  76.            cmp     al,27          ;is it escape?
  77.            je      boot5
  78.            cmp     al,13          ;is it return?
  79.            jne     boot3          ;if neither, read kb again
  80. boot5:     mov     bx,int8off     ;get original int 8 vector
  81.            mov     cx,int8seg
  82.            cli
  83.            mov     es:int8,bx     ;restore it in vector table
  84.            mov     es:int8+2,cx
  85.            sti
  86.            lea     si,dosboot     ;load DOS boot record address
  87.            cmp     al,27          ;escape = DOS
  88.            je      boot6
  89.            lea     si,os2boot     ;else load OS2 boot rec address
  90. boot6:     les     di,bootaddr    ;ES:DI --> load addr for boot rec
  91.            mov     cx,256         ;length of boot rec in words
  92.            rep     movsw          ;insert boot rec at boot address
  93.            pop     es             ;exit sequence
  94.            pop     ds
  95.            pop     di
  96.            pop     si
  97.            pop     cx
  98.            pop     bx
  99.            pop     ax
  100.            jmp     cs:bootaddr    ;branch to boot record
  101. asksys     endp
  102.  
  103. ; Int 8, timer tick hardware interrupt, is repointed here.
  104. ; This routine counts down a time value and chains to original INT 8.
  105.  
  106. timertick  proc
  107.            dec     cs:time
  108.            jmp     cs:oldint8
  109. timertick  endp
  110. code       ends
  111.            end
  112.