Re: 32.bit com
From: BSpider (NOSPAMpeterbls_at_o2.pl)
Date: 05/19/04
- Next message: The Wannabee: "Re: Enhanced Unicode support for "Go" tools"
- Previous message: Evenbit: "Re: Enhanced Unicode support for "Go" tools"
- In reply to: rjb: "Re: 32.bit com"
- Next in thread: BSpider: "Re: 32.bit com"
- Reply: BSpider: "Re: 32.bit com"
- Reply: rjb: "Re: 32.bit com"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 19 May 2004 22:52:30 +0200
Użytkownik "rjb" <nonesuch@here.com> napisał w wiadomości
news:c8gbiv$ha5$1@sparta.btinternet.com...
>
>
> There's something very peculiar about the way he writes code:
>
> ; test for DPMI
> xchg ax,bx
> int 2Fh
> sub ax,bx ; performs installation check and test for 32-bit host
> jnb ErrorExit
>
> That "xchg ax,bx" implies that there's something significant about the
value
> of bx when it goes into the interrupt. But its value is irrelevant. Why
> didn't he just write "mov ax,bx"? And that "sub ax,bx" leaves me
scratching
> my head. I can't decide whether it's particularly clever or plain daft.
The
> correct result depends upon ax being 0 and bx being 1. But bx holds the
flag
> value, according to RB's interrupt list. Stepping the instruction, I see
it
> coming out as 1, so I assume that "flag" just means the carry flag, not
the
> total flag register - i.e. it's either 0 or 1. In that case, I guess
it's
> clever, because "sub ax,bx" tests for the presence of DPMI (ax=0) and for
> 32-bit support (bx=1) with one instruction. If either condition failed,
the
> test would fail. (It looks to me like he's in some competition to see who
> can write the shortest startup code.)
>
Yes, sub ax,bx tests for those two conditions you mentioned (ax=0 and bx=1).
If either condition fails the program exits with an error.
>
> 1. I'm working through the DPMI v1.0 specs. It talks about running
different
> virtual machines simultaneously, but also different clients within the
same
> virtual machine. I'm trying to picture that from a practical point of
view -
> i.e. Windows. When you have, say, three DOS boxes sitting on your
task-bar,
> is that three virtual machines or three clients within one virtual
machine?
>
I'm not a Windows expert (yet :) and it's been a long time since I read the
DPMI specs (LOL, I only read the short version). Anyway, I think the answer
to your question would be that there are 3 clients within one virtual
machine under Windows. I wonder if anyone has more info on that. BTW Windows
9x/Me DPMI host is only version 0.9 (I don't know about XP's DPMI version
though).
> 2. In Tran's documents (I think it was) he talks about "raw mode". Does
that
> mean protected mode running at ring 0, or has it got some other meaning?
>
There are 3 main types of mode switching. When the processor is in V86 mode
the DOS extender should try to enter PMODE via DPMI first. Then, if DPMI is
not present it is supposed to switch modes via VCPI (it's a different
interface with it's own API, but AFAIK VCPI is not supporetd under Windows)
and simulate DPMI for the client by using VCPI calls. Finally, when the
processor is in REAL MODE at startup (not V86 mode - no drivers loaded or
only HIMEM.SYS XMS driver loaded under DOS) there is the so called RAW MODE
switching. It means that the DOS extender has to do all the mode switch
preparation work by himself (preparing the IDT, preparing the GDT, etc, etc)
and change cr0 register directly to switch modes. Then, the DOS extender
simulates DPMI for his client. When RAW MODE switching takes place protected
mode code usually runs at ring 0, but this is not guaranteed and some DOS
extenders might as well run user programs at ring 3.
> 3. What does "reentrant" mean, as in "All DPMI functions can be assumed to
> be reentrant unless otherwise stated." (DPMI specs)
>
"Reentrant" normally means that a function may be called again even if the
previous call to this function did not finish yet. When the DPMI host has
more clients (user programs) they can act just like they were alone. That
means, they don't have to test whether the host is free to call a
particulair DPMI function. For instance, the real DOS is not "reentrant" and
any DOS TSR should check the DOS busy flag before calling certain DOS
functions.
> 4. I'm still in the early part of the DPMI specs, so the answer might be
> provided eventually. But I looked briefly at an example program from one
> download, and noticed that the code seems to terminate with mov ah,4C/int
21
> when it's still in pmode. Is that possible? I thought all services in
pmode
> had to go via int 31h?
>
The DPMI host acts just like a typical DOS extender. It extends most of the
DOS INT 21h calls too. The mov ah,4ch/int 21h sequence will switch the
system back to real mode.
Ah, and one more thing. You won't be able to debug protected mode DPMI
programs with standard debuggers. As soon as your program enters 16-bit
protected mode your system will hang. If you definitely don't want to use
professional DOS extenders with advanced debuggers I suggest you try
TRW2000. It's a kernel mode debugger for Win9x/Me (it doesn't run under
WinXP or anything based on the NT kernel). It can debug any type of DOS
executable that normally runs under Windows. In the top right corner you'll
see the mode you're actually in. That is (V86, PM16 or PM32).
BSpider
- Next message: The Wannabee: "Re: Enhanced Unicode support for "Go" tools"
- Previous message: Evenbit: "Re: Enhanced Unicode support for "Go" tools"
- In reply to: rjb: "Re: 32.bit com"
- Next in thread: BSpider: "Re: 32.bit com"
- Reply: BSpider: "Re: 32.bit com"
- Reply: rjb: "Re: 32.bit com"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|