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