From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S272728AbTG1I2I (ORCPT ); Mon, 28 Jul 2003 04:28:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S272733AbTG1I2D (ORCPT ); Mon, 28 Jul 2003 04:28:03 -0400 Received: from fc.capaccess.org ([151.200.199.53]:27402 "EHLO fc.capaccess.org") by vger.kernel.org with ESMTP id S272728AbTG1I1e (ORCPT ); Mon, 28 Jul 2003 04:27:34 -0400 Message-id: Date: Mon, 28 Jul 2003 04:44:56 -0400 Subject: The Well-Factored 386 To: linux-kernel@vger.kernel.org, linux-assembly@vger.kernel.org From: "Rick A. Hohensee" MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org The four actual main modes of the 386 Operation of the INTeL 80386 is clearly much more flexible than currently used, as far as the basic states the machine can run in. "Real Mode" and "Protected Mode" are two possibilities out of several that are concievably useful. It can be seen from things that are possible in "Real Mode", such as "Unreal Mode", use of 386-era instructions and so on, that the canonical modes are not monolithic entities, but are cases of various combinations of discrete state switches. There is no 8086 in a 386. Canonical Wake-up Real Mode, which I will refer to as CWR Mode, seems to be how these several state switches are set at machine reset, but are semantically just settings of independant things, and clearly CWR Mode can be set up from individual settings available to the user. This is also much more evident from a careful traversal of the detailed instruction specs in the INTeL Programmer's Reference (386INTEL.TXT) for the 80386. I'd say the two most global switches in the machine are the PE bit, Protection Enabled, quite sensibly placed at bit 0 in control register 0, and the D bit of the active code segment descriptor affiliated with CS, the Default Bit. Two bits gives four possible states. All four are capable of being the default mode of a system. Two are used as such; CWR Mode and Protected Mode. Here's a breakdown and some neologizing... PE=0 Dbit=0 (un)Real Mode PE=0 Dbit=1 Forreal Mode PE=1 Dbit=0 Veal Mode (BKA "286 task") PE=1 Dbit=1 Protected Mode The documented modes are the outside cases in a binary-count listing, where PE=Dbit. There's a very good reason for that. IRET is sensitive to Dbit, whereas interrupts push a stack frame of operands sized in accordance with PE. This is some of INTeL's* description of the action of INT, which represents all interrupts in this regard, when PE=0... IF PE = 0 THEN GOTO REAL-ADDRESS-MODE; REAL-ADDRESS-MODE: Push (FLAGS); IF . global/flipPE # Welcome to Forreal Mode # cell still 4 = 4 to A # 32-bit schmegmented addressing demo = A to ES # proving we got PE = to 0. = 9348539 to A = A to @ $((0xb8a00)) ES = A to @ $((0xb8a00)) That code causes two identical attribute-glyph pairs to appear on the VGA text screen 32 charcells displaced from each other. That is the 4 in ES, times 16 as per 8086, divided by two since each charcell is 2 bytes. Plus a flat 32-bit address to put it on the screen. Forreal Mode thus does 32-bit 8086 schmegmented address computation. What is this type of addressing useful for? Precious little. In Forreal mode you've got 32 bits to start with. The point is you have the big flat segments left over from pmode. The 8086 address-math does prove we're not in pmode any more, however. Otherwise the ES prefix of 4 would have GPFed. Rick Hohensee Precision Mojo Engineer * I've converted my 386INTEL.TXT to 7-bit ASCII-art, not to mention op-source-dest and other unINTeLifications, and "