www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/17/03:40:44

Message-ID: <3265DD58.3721@rangenet.com>
Date: Thu, 17 Oct 1996 02:16:40 -0500
From: Dan Hedlund <markiv AT rangenet DOT com>
Reply-To: markiv AT rangenet DOT com
Organization: Range Net
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Are DPMI functions reenterent?

I've been using a dynamic stack instead of a static stack in my
interrupt routines.  Is it SAFE to call DPMI functions (501 and 502)
while servicing an interupt.  My program used to lock up when I used a
static stack.

Thanks, Dan.

Here's the source

.globl _S_snd_dig_int
_S_snd_dig_int:

        pushal                          // Save registers
        pushl   %ds
        pushl   %es
        pushl   %fs
        pushl   %gs

        movb    $0x20, %al              // Enable interupts
        outb    %al, $0x20
        movb    $0x20, %al
        outb    %al, $0xa0
        sti

        cld                             // Load selectors
        movl    %cs: _DataSel, %eax
        movw    %ax, %ds
        movw    %ax, %es
        movw    %ax, %fs
        movw    %ax, %gs

        movl    $0x0501, %eax           // Allocate a 64k stack
        movl    $0x0001, %ebx
        movl    $0x0000, %ecx
        intb    $0x31
        movl    %ebx, %eax
        shll    $16, %eax
        movw    %cx, %ax
        subl    _AbsoluteAddr, %eax
        addl    $0x10000, %eax

        movl    %esp, %ecx              // Save %ss:%esp
        movl    %ss, %dx

        pushl   _DataSel                // Load new stack
        pushl   %eax
        lss     (%esp), %esp

        pushl   %edx                    // Save old stack
        pushl   %ecx

        pushl   %esi                    // Save handle
        pushl   %edi

        call    _snd_dig_Int__Fv        // Call Interrupt Handler

        popl    %edi                    // Restore handle
        popl    %esi

        lss     (%esp), %esp            // Load old stack

        movl    $0x0502, %eax           // Free old stack
        intb    $0x31

        popl    %gs                     // Restore old registers
        popl    %fs
        popl    %es
        popl    %ds
        popal

        iretl                           // Return

-- 

*****      ***   **    **       Dan M. Hedlund
 ** **    *****  ***   **       <markiv AT rangenet DOT com>
 **  **  **   ** ****  **       http://www.rangenet.com/markiv
 **   ** **   ** ** ** **
 **   ** ******* **  ****
 **  **  **   ** **   ***
 ** **   **   ** **    **
*****    **   ** **    **

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019