home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / turpas70.zip / SOFTINT.ASM < prev    next >
Assembly Source File  |  2000-09-03  |  4KB  |  90 lines

  1. ;*******************************************************}
  2. ;                                                       }
  3. ;       Turbo Pascal Version 7.0                        }
  4. ;       Graphic Vision Unit (GDos)                      }
  5. ;                                                       }
  6. ;       Copyright 1997,2000 Jason G Burgon              }
  7. ;                                                       }
  8. ;*******************************************************}
  9.  
  10. IDEAL
  11. %TITLE "SOFTINT"
  12. %NOINCL
  13.  
  14. include "gdos.inc"
  15.  
  16. CODESEG
  17.     public SoftIntr     ; Call given application interrupt at Regs.CS:IP
  18.  
  19. ifndef _DPMI_
  20.  
  21.     public DosSoftIntr  ; Call given DOS/BIOS interrupt at Regs.CS:IP
  22.     public DosFarCall   ; Call given DOS/BIOS far procedure
  23.  
  24. ; function DosFarCall(var Regs: TRegisters): Word;
  25.  
  26.     proc DosFarCall
  27.             push  bp
  28.             mov   bp,sp
  29.             push  ds                      ; { Save global Data Segment      }
  30.             jmp   FarEnter
  31.     endp DosFarCall
  32.  
  33.     proc   DosSoftIntr  ; Same as SoftIntr in real mode
  34. endif
  35.  
  36. ; function SoftIntr(var Regs: TRegisters): Word;
  37.  
  38. P8086
  39. proc SoftIntr Regs: PRegisters
  40.             push  ds                      ; { Save global Data Segment      }
  41. P386N
  42.             pushf                         ; { Push flags for the IRET       }
  43. FarEnter:   lds   si,[Regs]
  44.             push  cs                      ; { Push return address           }
  45.             mov   eax,[si+TRegisters.EAX] ; { Load the registers for intrpt }
  46.             push  offset @@Retn
  47.             mov   ebx,[si+TRegisters.EBX]
  48.             push  [si+TRegisters.CS]      ; { Push ISR call address (CS)    }
  49.             mov   ecx,[si+TRegisters.ECX]
  50.             mov   edx,[si+TRegisters.EDX]
  51.             push  [si+TRegisters.IP]      ; { Push ISR call address (IP)    }
  52.             mov   edi,[si+TRegisters.EDI]
  53.             mov   es,[si+TRegisters.ES]
  54.             push  [si+TRegisters.ESI]     ; { Push Regs.ESI                 }
  55.             mov   ebp,[si+TRegisters.EBP]
  56.             mov   ds,[si+TRegisters.DS]   ; { DS = Regs.DS                  }
  57.             pop   esi                     ; { ESI = Regs.ESI                }
  58.             retf  0                       ; { Far Call the ISR              }
  59.  
  60. @@Retn:     push  ebp                     ; { Push new Regs.EBP             }
  61.             pushf                         ; { Push new Regs.Flags           }
  62.             mov   bp,sp                   ; { Restore stack frame           }
  63.             push  ds                      ; { Push new Regs.DS              }
  64.             add   bp,6                    ; { Move past Flags, BP and DS    }
  65.             push  esi                     ; { Push new Regs.ESI             }
  66.             lds   si,[Regs]               ; { DS:SI = @Regs                 }
  67.             mov   [si+TRegisters.EAX],eax
  68.             mov   [si+TRegisters.EBX],ebx
  69.             mov   [si+TRegisters.ECX],ecx
  70.             mov   [si+TRegisters.EDX],edx
  71.             mov   [si+TRegisters.EDX],edi
  72.             mov   [si+TRegisters.ES],es
  73.             pop   [si+TRegisters.ESI]     ; { pop new Regs.ESI              }
  74.             pop   [si+TRegisters.DS]      ; { pop new Regs.DS               }
  75.             pop   [si+TRegisters.Flags]   ; { pop new Regs.Flags            }
  76.             pop   [si+TRegisters.EBP]     ; { pop new Regs.EBP              }
  77.             pop   ds                      ; { Restore global Data Segment   }
  78. P8086
  79.             ret
  80. endp SoftIntr
  81.  
  82. ifndef _DPMI_
  83.  
  84. endp DosSoftIntr
  85.  
  86. endif
  87.  
  88. ends
  89. end
  90.