• Please review our updated Terms and Rules here

we need more programming discussion

"The 80386 introduced 'virtual 8086' mode. The host OS sets up memory a memory region which looks like classic flat real mode addressing inside of the virtual 8086."

Don't you mean segmented addressing? Or does that happen when virtual-8086 mode gets wrapped up into a command prompt?

"When in virtual 8086 mode the processor behaves just like a real 8088/8086, but with some differences. You can alter memory all you want, but touching I/O ports is a bit of a problem. The host OS has to intercept and decide whether to pass the request through to real hardware, emulate it, or do something else. Depending on the host OS that gives you the ability to touch real hardware directly."

real mode (which even modern processors start up in, then get switched to protected mode by the OS) and virtual-86 mode are two different things though. A processor/OS setups up a virtual machine (or multiples), and that becomes a process as you pointed out. I'm not nitpicking, just trying to understand and get the terminology correct. Then again maybe that is nitpicking...
From what I've read in the distant past, M$ took part in the design of virtual-86 mode, which in reality makes sense because the major impetus was probably to create an environment for all the legacy code built on top of their premier OS. So then, the implementation of a "DOS" prompt was for the purpose of allowing nasty messy old dos apps to run eh unimpeded, so it's going to have to allow low level hardware calls and such, regardless if this is by emulation or not. Printer access and even disk access could be issues, but I thought that disk sectors could be altered (floppy anyway) at least with W95-98. Those are "peripheral" issues though (for many programs, except things like disk editors and whatnot), and "typical" low level access has to be allowed - like accessing the timer chip or whatever.

"You could literally boot DOS 5 in a window..."

If you "run" command.com from the start button, you're executing dos (or at least that version that's specific to the os you're using). NT based OS' aren't "integrated" with a 16 bit dos obviously, so you're running something else? (and please let's not get into a discussion over my using that once nasty nasty term from the Chicago days - integration. I probably should have chose something else altogether).
It's been said on classiccmp recently that you can execute windoze 3.11 (and anything else earlier?) from the command prompt or? run prompt.

"It's certainly easier to exploit a virtual 8086 than it is to write an emulator, but you need access to the host OS."

via DLL's and whatnot?

So essentially I was thinking along the lines that something like the Tandy 2000 could be emulated using virtual-86 mode, depending on if/how you get to tailor the access to low level stuph. Just food for thought.
 
My bad. 'Flat' is a bad word considering that it is segmented, but compared to having to have page tables, TLBs and demand paging it's pretty flat. It actually is good old segmented 8086.

real mode (which even modern processors start up in, then get switched to protected mode by the OS) and virtual-86 mode are two different things though.

I never said real mode, or discussed real vs. protected. I used the word real to describe how the virtual 8086 interacts with hardware. It's almost like being on real hardware, except for the obvious security problems with allowing unfettered access to I/O ports.

I don't think that running 'command' or 'cmd' from the Start->Run option on Windows gives you a virtual 8086. It looks more like a DOS emulator. If it really were a virtual 8086, it would go through a boot sequence and load DOS from somewhere, and you couldn't access the rest of the Windows NTFS filesystem.
 
"I never said real mode, or discussed real vs. protected. I used the word real to describe how the virtual 8086 interacts with hardware. It's almost like being on real hardware, except for the obvious security problems with allowing unfettered access to I/O ports."

I know you didn't. I was trying to respond to *something*. Maybe it was in a different part of your post. Frankly can't remember.
The reality though is that real mode and virtual-86 mode are sort of similar, but entirely different. O man whatever.

"I don't think that running 'command' or 'cmd' from the Start->Run option on Windows gives you a virtual 8086. It looks more like a DOS emulator. If it really were a virtual 8086, it would go through a boot sequence and load DOS from somewhere, and you couldn't access the rest of the Windows NTFS filesystem."

I seem to recall that in Chuck Sphar's book "Learn Visual C++ 6.0 NOW" he stated that a set of win32 API's are used to not only create the command prompt environment (on the backbone of virtual-86 mode) but the dos-like environment for a console application as well. It's been years, and it amazes me how these things come back to me. I'll have to take another look.
Maybe you're only working in virtual-86 mode with non-NT based OS', or just that the NT "command.com" is just a totally different animal that's programmed to access NTFS partitions. If anyone owns any copy of "Inside Windows" (NT,2000,...), they could probably look it up. I actually may have one copy at mom's house...
 
I took another look at the book I mentioned, and v86 mode isn't even mentioned (can't we assume that it's invoked when a dos box is opened, at least with Win9x, ME?). I think my original readings on v86 mode came from a book called the UNAUTHORIZED Windows 95 Developer's Resource Kit
by Andrew Schulman. An interesting book, based on the beta ("Chicago"), which gets pulled apart by the author, but mostly (though not entirely) useless for today's stuph, given the defunct status of that branch of the Windows family.

Online tutorial for 386 stuph:

http://pdos.csail.mit.edu/6.828/2006/readings/i386/c15.htm
 
I took another look at the book I mentioned, and v86 mode isn't even mentioned (can't we assume that it's invoked when a dos box is opened, at least with Win9x, ME?)...
No, DOS emulation wouldn't necessarily have to be done with V86 mode...
 
Last edited:
An interesting book, based on the beta ("Chicago"), which gets pulled apart by the author, but mostly (though not entirely) useless for today's stuph, given the defunct status of that branch of the Windows family.

Maybe the beta didn't have the debug info stripped, hence was easier to pull apart... and yes, mostly useless now because NT/XP is a different system, just with the same first name (and mostly compatible api).

On a side note, I remember using "Memphis" (aka windows 97) for a good few years on a daily basis on my PC... Now I'm using Win98 SE. Guess I'm a bit dephunct... :sarcasm:
 
the author could have pulled it apart regardless. If you've never taken a look at the book, it's a worthwhile read. At some point they're probably going to be hard to find, so maybe get one now while the getting is good ;)
 
No, DOS emulation wouldn't necessarily have to be done with V86 mode...

well...according to Wikipedia:

"It is used to execute DOS programs in Microsoft Windows/386 and Windows 3.x and Windows 9x and Windows Me and OS/2 2.x and later through Virtual DOS machines, in SCO UNIX through Merge and in Linux through dosemu."

The question wasn't if it HAD to be done w/v86 (in Win9x and ME as I pointed out) but IF it were done that way. Apparently it was...

But let me just say I'm so glad we're all paying attention to each other's posts...
 
I don't believe everything I read in Wikipedia since I recently had an argument with somebody claiming that interpreted BASIC was almost as fast as compiled BASIC.


I think this page has a great description:

http://www.online.ee/~andre/i80386/Chap15.html

Running 'DEBUG' in a DOS window on my Windows 2000 machine showed me this:

Code:
C:\WINNT\system32>debug
-r
AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0B16  ES=0B16  SS=0B16  CS=0B16  IP=0100   NV UP EI PL NZ NA PO NC
0B16:0100 83C205        ADD     DX,+05

Note the absence of extended registers .. this really does look like an 8086.

On the other hand:

Code:
C:\WINNT\system32>mem


    655360 bytes total conventional memory
    655360 bytes available to MS-DOS
    633184 largest executable program size

   1048576 bytes total contiguous extended memory
         0 bytes available contiguous extended memory
    941056 bytes available XMS memory
           MS-DOS resident in High Memory Area

C:\WINNT\system32>

If this really is a virtual 8086, how can it claim to have extended memory? XMS yes, but extended is not possible unless you are on a 286 or greater.

So, I don't know exactly what is doing on here ..
 
I don't believe everything I read in Wikipedia since I recently had an argument with somebody claiming that interpreted BASIC was almost as fast as compiled BASIC.
Yes, and I have seen articles that are just flat out wrong...

I think this page has a great description:
http://www.online.ee/~andre/i80386/Chap15.html
Running 'DEBUG' in a DOS window on my Windows 2000 machine showed me this:...
...If this really is a virtual 8086, how can it claim to have extended memory? XMS yes, but extended is not possible unless you are on a 286 or greater.
So, I don't know exactly what is doing on here ..
To be fair this is Windows 2000. For at least the NT+ angle who better to ask than Microsoft?: http://support.microsoft.com/?kbid=99279
"...Although the concept of running an MS-DOS-based application in a Windows-based environment may be familiar to you, Windows NT handles this somewhat differently than Windows (16-bit) does.
The essential difference lies in the command prompt itself; under Windows NT, the command prompt is a 32-bit Windows NT-based application, not the virtual MS-DOS machine you would expect from Windows..."

Later there is talk of PIF files, which have been with Windows since at least 3.x (although the focus area I am looking at is whether EMS can be allocated in a Windows 3.x PIF). And Windows 3.x in "Standard Mode" (286, 386 without at least 2Mb, or 386 with enough RAM but throttled from the commandline) can run DOS boxes (the more limited Windows 3.0 "Real Mode", able to run on an 8086/8088, has to totally shut out of the Windows interface to bring up DOS) where the 286 CPU is not capable of doing V86 mode.
 
Last edited:
...Later there is talk of PIF files, which have been with Windows since at least 3.x (although the focus area I am looking at is whether EMS can be allocated in a Windows 3.x PIF). And Windows 3.x in "Standard Mode" (286, 386 without at least 2Mb, or 386 with enough RAM but throttled from the commandline) can run DOS boxes (the older "Real Mode", able to run on an 8086/8088, has to totally shut out of the Windows interface to bring up DOS) where the 286 CPU is not capable of doing V86 mode.
Ok, I found a very good reference right in my own library. "Undocumented DOS", by Andrew Schulman, Ralf Brown [care to dispute him?], David Maxey, Raymond J. Michels, & Jim Kyle. The book is written pre-Windows 95 (which it calls by the codename "Chicago"). Even Windows is discussed more in the terms of 3.0, going over Real, Standard, & Enhanced modes.

Enhanced Mode & Standard mode run the DOS boxes differently. With Enhanced Mode, they say that the code is in the "DOSMGR" VxD, which "is a piece of 32-bit protected mode code running at Ring 0...". In Standard mode (and remember this is normally running on a 286, not able to do V86 mode) it was a DOS extender called DOSX.EXE.

The most talk (of course) is about the Enhanced mode. Notable there is another unassociated VxD called V86MMGR (which manages the EMS 'M'emory for V86 mode). Too much to condense here (and the authors say there was too much material to put in a single book) & an interesting read.
 
so did either of you gurus figure out whether a dos-prompt environment in Win 9x or ME rides on the back of V86 mode? That was was prompted this arm of the discussion...

"(the older "Real Mode", able to run on an 8086/8088, has to totally shut out of the Windows interface to bring up DOS)"

"Real Mode" is very much a part of every peecee, even today's. Even a P4 starts up in real mode, then gets switched to protected mode by Winders or whatever OS that plans to run in it. You can boot up in dos by simply placing a dos disk in the drive (or cd, or a dos partition on a hard drive) and turning on the machine. Then it looks to the OS (dos) like a really really fast 8086, 1 megabyte address space, etc. W/O switching to protected mode, that's where the machine will stay.
To run DOS within Winders or Linux or OS/2...you need some sort of emulation, either in v86 mode, or whatever NT/Linaches/OS/2 etc. uses. Something like that...
 
Hello Mike,

In your sample program:

Code:
DIM asmStringData AS STRING
asmStringData = blahblahblah pre-compiled ASM code here, make sure you add a RET opcode at the end

DEF SEG = VARSEG(asmStringData)
CALL ABSOLUTE (SADD(asmStringData))

VARSEG and SADD are used to provide the location (address) of the asmStringData,
because after the first declaration:

DIM asmStringData AS STRING

It is DOS that has established where asmStringData would be. Do I understand this correctly?
 
Hello Mike,

In your sample program:



VARSEG and SADD are used to provide the location (address) of the asmStringData,
because after the first declaration:

DIM asmStringData AS STRING

It is DOS that has established where asmStringData would be. Do I understand this correctly?

yup, thats right. you actually don't even need the DIM statement, as long as you put a $ at the end of asmStringData since qb will automatically have to establish a place to put it.
 
Back
Top