Announcement

Collapse
No announcement yet.

PB/DOS - Interrupt-Vector functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB/DOS - Interrupt-Vector functions

    Code:
    '------------------------------------------------------------------------------
    '          Unit: pointer2.pbl
    '         Zweck: Adressumwandlungen, Interruptvektor-Funktionen
    '         Autor: M.Hoffmann
    '       Sprache: PowerBASIC 3.5
    ' 1.00 19.12.94: erste Version POINTER1.
    ' 1.10 07.05.98: Interne Optimierungen; ACHTUNG: wegen BYVAL-Aufruf geänderte
    '                Deklarationen im Hauptprogramm erforderlich, daher als
    '                POINTER2 weiterentwickelt!
    ' 1.20 05.07.98: Optimierungen.
    '------------------------------------------------------------------------------
    ' c: pointer1.pbu      1858   5.04.98  14:42 v1.00 POINTER1 (PB)
    ' c: pointer2.pbu      1350   7.05.98  18:58 v1.10 POINTER2 (ASM)
    ' c: pointer2.pbu      1133   5.07.98  13:48 v1.20
    
    $compile  unit
    $cpu      80386
    $debug    map-,pbdebug-,path-,unit-
    $dim      all
    $error    bounds-,numeric-,overflow-,stack-
    $event    off
    $optimize size
    $option   cntlbreak-,gosub-,signed-
    $static
    
    '
    ' --- Wandelt Segment- und Offset-Teil einer Adresse in einen Pointer um
    '
    
    function farptr (byval segm as word, byval offs as word) local public as dword
       ! mov ax, segm
       ! mov function[2], ax
       ! mov ax, offs
       ! mov function[0], ax
    end function
    
    '
    ' --- Ermittelt den Segment-Teil eines Pointers (DWORDs)
    '
    
    function segment (byval farp as dword) local public as word
       ! mov ax, word farp[2]
       ! mov function, ax
    end function
    
    '
    ' --- Ermittelt den Offset-Teil eines Pointers (DWORDs)
    '
    
    function offset (byval farp as dword) local public as word
       ! mov ax, word farp[0]
       ! mov function, ax
    end function
    
    '
    ' --- Gibt einen Interruptvektor als Pointer zurück (&hffffffff = Fehler)
    '
    
    function getintvec (byval intnr as byte) local public as dword
       ! pushf
       ! mov function, &hffffffff
       ! mov ah, &h35
       ! mov al, intnr
       ! int &h21
       ! jc getintvecX
       ! mov function[0],bx
       ! mov function[2],es
    getintvecX:
       ! popf
    end function
    
    '
    ' --- Setzt einen Interruptvektor auf die als Pointer übergebene Adresse
    '        Anmerkung: gibt 0 oder Fehlercode vom DOS zurück.
    '
    
    function setintvec (byval intnr as byte, byval farp as dword) local public as integer
       ! pushf
       ! push ds
       ! mov ah, &h25
       ! mov al, intnr
       ! mov ds, word farp[2]
       ! mov dx, word farp[0]
       ! int &h21
       ! jc setintvecX
       ! xor ax,ax
    setintvecX:
       ! pop ds
       ! popf
       ! mov function,ax
    end function
    
    '===============================================================================
    ------------------
Working...
X