home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / PCCBRK.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-10-19  |  2.4 KB  |  121 lines

  1. ; pccbrk.asm
  2. ;
  3. ; 10/11/90 by Ted
  4. ;
  5. ; Low level function for Oakland CTL-BRK detection.
  6. ;
  7. ; OWL-PCA 1.2
  8. ; Copyright (c) 1988, 1989 Oakland Group Inc.
  9. ; ALL RIGHTS RESERVED
  10. ;
  11. ;------------------------REVISION HISTORY--------------------------------------;
  12. ;
  13. ;------------------------------------------------------------------------------;
  14. include    PCDECL.MAC
  15.  
  16.     PSEG
  17. ; ---------------------------------------------------------------- ;
  18. ; ******* data in code segment *********
  19.  
  20. cbrk    dw 0
  21. initted    dw 0
  22. brk1b    dd ?
  23. ; ---------------------------------------------------------------- ;
  24. ; Int 1B vector catch - sets flag for control-break gotten
  25.  
  26. flagset proc far
  27.     mov cs:cbrk, 1        ; set our cbrk flag
  28.     iret
  29. flagset endp
  30. ; ---------------------------------------------------------------- ;
  31. ; Repoint vector for break interrupt to our code.
  32. ; void DIGPRIV pc_catchcbrk(void);
  33.  
  34. pubproc DIGPRIV pc_catchcbrk
  35.     push bp
  36.     mov bp,sp
  37.     push es
  38.  
  39.     mov cs:initted, 1
  40.  
  41.     cli
  42.  
  43. ; Get the int 1B vector that bios has set up
  44.     mov al, 1Bh
  45.     mov ah, 35h
  46.     int 21h
  47.     mov word ptr cs:brk1b, bx
  48.     mov word ptr cs:brk1b+2, es
  49.  
  50. ; Set int 1B vector to point to flag setter routine
  51.     push ds
  52.     push cs
  53.     pop ds
  54.  
  55.     mov al, 1Bh
  56.     mov ah, 25h
  57.     mov dx, offset flagset
  58.     int 21h
  59.  
  60.     pop ds
  61.  
  62.     sti                    ; allow interrupts now
  63.  
  64. nocatch:
  65.     pop es
  66.     pop bp
  67.     ret
  68. endproc pc_catchcbrk
  69.  
  70. ; ---------------------------------------------------------------- ;
  71. ; Restore the cbrk addresses
  72. ; void DIGPRIV pc_restorecbrk(void);
  73.  
  74. pubproc DIGPRIV pc_restorecbrk
  75.     push bp
  76.     push ds
  77.  
  78.     cmp cs:initted, 0
  79.     je nofix
  80.     
  81. ; Restore the int 1B ctl break vector
  82.     mov al, 1Bh
  83.     mov ah, 25h
  84.     mov dx, word ptr cs:brk1b
  85.     mov bx, word ptr cs:brk1b+2
  86.     mov ds, bx
  87.     int 21h
  88.  
  89.     mov cs:initted, 0
  90. nofix:
  91.     pop ds
  92.     pop bp
  93.     ret
  94. endproc pc_restorecbrk
  95. ; ---------------------------------------------------------------- ;
  96. ; Check the cbrk flag, and reset it if the cleanup flag is TRUE
  97. ; boolean DIGPRIV pc_checkcbrk(int cleanup);
  98.  
  99. pubproc DIGPRIV pc_checkcbrk <cleanup>
  100.     push bp
  101.     mov bp,sp
  102.  
  103. ; Get the code into ax, and clear it if cleanup is not 0
  104.     cli
  105.     mov ax, cs:cbrk
  106.     
  107.     cmp word ptr [bp].cleanup, 0
  108.     je noclean
  109.     mov cs:cbrk, 0
  110. noclean:
  111.     sti
  112.  
  113.     pop bp
  114.     ret
  115. endproc pc_checkcbrk
  116. ;------------------------------------------------------------------------------;
  117.     ENDPS
  118.     end
  119. ;------------------------------------------------------------------------------;
  120.  
  121.