[comp.os.msdos.programmer] 80286 protected mode programming

bianco@cs.odu.edu (David J. Bianco) (07/31/90)

How does one kick the 286 chip into protected mode? I'm using TC++ (but
only, as of yet, in TC mode, not TC++ mode), and was hoping to get out
of this segmented architecture via the protected mode. Since I dont
really care if my program will run in the background of a multitasker
or anything, I thought this would be a good solution.  

nmouawad@water.waterloo.edu (Naji Mouawad) (07/31/90)

In article <BIANCO.90Jul30163028@daffodil.cs.odu.edu> bianco@cs.odu.edu
(David J. Bianco) writes:

>How does one kick the 286 chip into protected mode? I'm using TC++ (but
>only, as of yet, in TC mode, not TC++ mode), and was hoping to get out
>of this segmented architecture via the protected mode. Since I dont
>really care if my program will run in the background of a multitasker
>or anything, I thought this would be a good solution.  

I don't get it. If you set the processor in protected mode, you kill
Dos (Are you using Dos ?) and unless you use fancy tricks as the ones used
by Windows and the like, any interrupt service will not be carried away 
by DOS. Thus, you're program won't be able to read a file or send a
character to the printer etc...

Unless you have an operating system that supports the protected mode,
you can't do much of it... but then again, I may be wrong.

-- 
         ---------------+-------------------------------------------
        | Naji Mouawad  |       nmouawad@water.uwaterloo.edu        |
        |  University   |-------------------------------------------|
        | Of Waterloo   | "Thanks God, we cannot prove He Exists."  |

ganter@urz.unibas.ch (08/05/90)

In article <BIANCO.90Jul30163028@daffodil.cs.odu.edu>, bianco@cs.odu.edu (David J. Bianco) writes:
> How does one kick the 286 chip into protected mode? I'm using TC++ (but
> only, as of yet, in TC mode, not TC++ mode), and was hoping to get out
> of this segmented architecture via the protected mode. Since I dont
> really care if my program will run in the background of a multitasker
> or anything, I thought this would be a good solution.  

quite complicated without any BIOS-listing. Try to get a IBM-AT Technical
Reference Manual Vol.1, there You find the complete BIOS-listing, useful 
anyway. 
You have to prepare some tables (GDT,IDT,etc.) to switch to protected
mode. And then you have to care about protection violation caused by improper
linking, and so on ... 
Use the technical reference and a good book on the 286.

Robert

rcollins@altos86.Altos.COM (Robert Collins) (08/09/90)

In article <1990Jul31.024249.1328@water.waterloo.edu> nmouawad@water.waterloo.edu (Naji Mouawad) writes:
>In article <BIANCO.90Jul30163028@daffodil.cs.odu.edu> bianco@cs.odu.edu
>(David J. Bianco) writes:
>
>>How does one kick the 286 chip into protected mode? I'm using TC++ (but
>>only, as of yet, in TC mode, not TC++ mode), and was hoping to get out
>>of this segmented architecture via the protected mode. Since I dont
>>really care if my program will run in the background of a multitasker
>>or anything, I thought this would be a good solution.  
>

Don't try and use the '286 to circumvent the necessity for segmentation.
The '286 in protected mode enforces segmentation much stronger than in
real mode.  I would recommend getting a good book that discusses
protected mode, and read it.  

I just finished writing two magazine articles on how to enter and
leave protected mode, along with lots of undocumented goodies about
the '286 and '386.  At this point I don't know if they will be accepted
for publication (as each article is 8-10 pages, and includes 20 or more
pages of figures and source code).  If the articles are accepted, you
can read them in TECH SPECIALIST in a couple of months.  If they are
rejected, then I will post them to the net.

Robert Collins
 

alanw@ashtate (Alan Weiss) (08/22/90)

In article <1990Jul31.024249.1328@water.waterloo.edu> nmouawad@water.waterloo.edu (Naji Mouawad) writes:
>In article <BIANCO.90Jul30163028@daffodil.cs.odu.edu> bianco@cs.odu.edu
>(David J. Bianco) writes:
>
>>How does one kick the 286 chip into protected mode? I'm using TC++ (but
>>only, as of yet, in TC mode, not TC++ mode), and was hoping to get out
>>of this segmented architecture via the protected mode. Since I dont
>>really care if my program will run in the background of a multitasker
>>or anything, I thought this would be a good solution.  
>
>I don't get it. If you set the processor in protected mode, you kill
>Dos (Are you using Dos ?) and unless you use fancy tricks as the ones used
>by Windows and the like, any interrupt service will not be carried away 
>by DOS. Thus, you're program won't be able to read a file or send a
>character to the printer etc...
>
>Unless you have an operating system that supports the protected mode,
>you can't do much of it... but then again, I may be wrong.
>
>-- 
>         ---------------+-------------------------------------------
>        | Naji Mouawad  |       nmouawad@water.uwaterloo.edu        |

No, you're (partially) correct, Naji.  Once in Protected Mode (286-style),
DOS no longer knows who/what/where you are.  Products such as DOS Merge
(Locus Computing, Inglewood CA) use Unix to control the machine.  Some
operating systems (BTOS/CTOS from Unisys/Convergent) offer a *REAL*
operating system that allows programmers to write protected mode
applications and/or system software using real-mode stubs).

'Course, you could always write your own protected-mode monitor program/
mini-OS to manage the environment (which is what Windows does).

This is not especially easy, but others have done this (Windows, OS/2
with the Compatibility Box, DOS Merge, VP/ix, BTOS/CTOS, DESQview, etc.)

Good luck.

........................................................................
|	Alan R. Weiss     |	Ashton-Tate Corporation			|	
|	213-538-7584      | My employer can express its own opinions,   |
|       alanw@ashton      | thank you!  These are mine for the taking.  |
|!uunet!ashtate!alanw     |---------------------------------------------|
|alanw@ashtate.A-T.com    | Fight organized crime ... eliminate the IRS |
|Or try using "R" or "r"  | The Net is the last bastion of liberty!     |
..........................|..............................................