delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/18/13:15:04

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "MarKol" <markol4 AT wp DOT pl>
Newsgroups: comp.os.msdos.djgpp
Subject: DS and ESP
Date: Mon, 18 Feb 2002 10:26:13 +0100
Organization: tp.internet - http://www.tpi.pl/
Lines: 70
Message-ID: <a4rfgu$sbg$1@news.tpi.pl>
NNTP-Posting-Host: seazone.gda.pl
Mime-Version: 1.0
X-Trace: news.tpi.pl 1014055262 29040 195.117.175.253 (18 Feb 2002 18:01:02 GMT)
X-Complaints-To: usenet AT tpi DOT pl
NNTP-Posting-Date: Mon, 18 Feb 2002 18:01:02 +0000 (UTC)
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MSMail-Priority: Normal
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi

I'm developing some kind of simple API (as a library) to install
protected
mode interrupts under DJGPP. I dont't use standard DPMI functions to
install
interrupts. Instead i create some alias descriptors in LDT and install
my service
routines directly in IDT (it works under DOS and CWSDPMI only but its
sufficient
for me). Everything seems work correctly but:

1) I've written assembly stubs (NASM od course ;-) ). Thank to this, I
can
   install service routines written in C. The problem is when interrupt
   comes, program flow is redirected via interrupt gate in IDT to my
   assembly stub routine (note that interrupts are automatically
disabled).
   In this stub routine I assume 2 things:
 a) ds segment always contains selector for .data segment.
    In my library functions I don't break this rule and ds is always
valid
    (If I really need to change ds I'm blocking interrupts for a while
    when ds is invalid).
   +I wonder if gcc, doesn't change ds?
    I think that there no need to change to change ds for compiler but
    I'm not sure about this.
   +Are DJGPP's libc function conform to his rule?
    In other words I wonder in there is some piece of code in DJGPP's
libc
    which may be executed during normal program flow (not loading
    or ending),  and changes ds selector (and it is possible
    to accept HW interrupt by CPU at ehis moment)?

    I was thinking how to cope with this problem in case ds isn't
    always valid (when user code executes and HW interrupt may be
accepted
    by CPU). Any ideas?

 b) similar problem is about esp (I belive that ss is valid ).
    My stub routine assumes that valid program data on stack are
    pointed by esp and higher values. Anything below esp is not
    important for the program. But I've seen codes like this
    (simple but ilustrates problem accessing stack segment below esp,
     maybe programmer thought that nothing wrong can happen):

    mov   [esp-4],    eax
    shl   eax,        cl
    add   [edi],      eax
    mov   eax,        [esp-4]

    If HW interrupt will be accepted between eax is restored there
    are valid program data on the stack below esp. My asm stub uses
    user stack below esp, and assumes there is no valid
    user data below esp (it uses 8 bytes for ss and esp)

    I belive that GCC doesn't generate code like above and
    there is no such incoherenties in DJGPP's libc.


 Any help would be appreciated.

best regards
--
  /     |_|_|_|_|     void identification(){               \
 /       |mov e|        printf("   Marek  Kolacz  ");       \
||       |cld  |        printf("   markol4 AT wp DOT pl  ");       ||
 \       |movsd|      }                                     /
  \_____/_______\__________________________________________/

- Raw text -


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