home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / help / tphelp / tphelp.asm < prev    next >
Encoding:
Assembly Source File  |  1988-02-10  |  2.7 KB  |  108 lines

  1. ;Assembly language file for TPHELP unit
  2. ;Written by Kim Kokkonen, TurboPower Software
  3. ;Version 1.0, 2/7/88
  4. ;  initial release
  5. ;Version 1.1
  6. ;  support enhanced keyboard calls in int16 handler
  7. ;Copyright (c) 1988 TurboPower Software
  8. ;may be used freely by owners of Turbo Professional
  9.  
  10. StackSize    =    2000        ;Size of alternate stack
  11.  
  12. DATA    SEGMENT BYTE PUBLIC
  13.     EXTRN    CurrentTopic : WORD    ;Current help topic
  14.     EXTRN    SaveInt16 : DWORD    ;Old value of int 16
  15.     EXTRN    HelpSystem : DWORD    ;Pointer to initialized help system
  16.     EXTRN    HelpActive : BYTE    ;1 if help system on screen, else 0
  17.     EXTRN    HelpKey : WORD        ;Scan word for help
  18.     EXTRN    StackSpace : DWORD    ;Pointer to alternate stack
  19.  
  20. CurSP    DW    ?            ;Stack position when help activated
  21. CurSS    DW    ?
  22. AXentry DW    ?            ;AX on entry to interrupt
  23.  
  24. DATA    ENDS
  25.  
  26. CODE    SEGMENT BYTE PUBLIC
  27.  
  28.     ASSUME  CS:CODE, DS:DATA
  29.     EXTRN    ShowHelp : NEAR        ;Actually FAR, be careful!
  30.     PUBLIC  Int16Handler
  31.  
  32. CSInt16 LABEL    DWORD
  33. Int16Ofs    DW    ?
  34. Int16Seg    DW    ?
  35.  
  36. ;*********************************************************** NewInt16
  37. ;Handle software keyboard interrupts
  38. Int16Handler PROC FAR
  39.     PUSH    DS            ;Save registers we use
  40.     PUSH    AX
  41.     MOV    AX,SEG DATA
  42.     MOV    DS,AX            ;Set DS to Turbo segment
  43.     POP    AX            ;Restore AX
  44.     STI                ;Allow interrupts
  45.     CMP    HelpActive,0        ;Help already on screen?
  46.     JNZ    Chain16            ;Yes, pass on to old int 16
  47.     MOV    AXentry,AX        ;Save AX for retry
  48.     OR    AH,AH            ;Reading a key?
  49.     JZ    GetKey            ;Yes, read it
  50.     CMP    AH,10h            ;Reading a key with enhanced BIOS?
  51.     JZ    GetKey            ;Yes, read it
  52. Chain16:                ;Transfer to old int16
  53.     PUSH    AX
  54.     MOV    AX,WORD PTR [SaveInt16]
  55.     MOV    Int16Ofs,AX
  56.     MOV    AX,WORD PTR [SaveInt16+2]
  57.     MOV    Int16Seg,AX        ;Set up CS-relative int16
  58.     POP    AX
  59.     POP    DS
  60.     JMP    CSInt16            ;Back to old int16
  61. GetKey:
  62.     PUSHF                ;Keep IRET happy
  63.     CALL    SaveInt16        ;Emulate call to old int16
  64.     CMP    AX,HelpKey        ;Is it help key?
  65.     JZ    GotHelpKey        ;Yes, put up help
  66.     POP    DS            ;No, restore DS
  67.     IRET                ;Back to caller
  68. GotHelpKey:
  69.     MOV    HelpActive,1        ;Set flag to avoid re-entry
  70.     MOV    CurSS,SS        ;Save current stack position
  71.     MOV    CurSP,SP
  72.     MOV    AX,WORD PTR [StackSpace]
  73.     ADD    AX,StackSize
  74.     CLI                ;Switch to big stack
  75.     MOV    SS,WORD PTR [StackSpace+2]
  76.     MOV    SP,AX
  77.     STI
  78.     PUSH    BX            ;Save rest of registers
  79.     PUSH    CX
  80.     PUSH    DX
  81.     PUSH    SI
  82.     PUSH    DI
  83.     PUSH    ES
  84.     PUSH    BP
  85.     PUSH    WORD PTR [HelpSystem+2] ;Parameters for call
  86.     PUSH    WORD PTR [HelpSystem]
  87.     PUSH    CurrentTopic
  88.     PUSH    CS            ;Simulate far call
  89.     CALL    ShowHelp        ;Call display routine, ignore function result
  90.     POP    BP
  91.     POP    ES
  92.     POP    DI
  93.     POP    SI
  94.     POP    DX
  95.     POP    CX
  96.     POP    BX
  97.     CLI
  98.     MOV    SS,CurSS        ;Back to original stack
  99.     MOV    SP,CurSP
  100.     STI
  101.     MOV    HelpActive,0        ;Help no longer active
  102.     MOV    AX,AXentry        ;Restore initial AX
  103.     JMP    GetKey            ;Get another key before returning
  104. Int16Handler ENDP
  105.  
  106. CODE    ENDS
  107.     END
  108.