Real Mode

What is Real Mode?

Real mode basically refers to a particular type of operating mode used by the Intel 286 and later processors. This mode allows these processors to support the traits of other lower processors such as 8086 or 8088 processors.

Technically, operating in the real mode allows the processors to run older software programs and at the same time ensures that they operate at a reasonably higher clock speed.

Understanding Real Mode

Understanding Real Mode

Real mode, also known as real address mode, is so called because the addresses in the real mode match the real locations in the memory all the time.

The program can access it irrespective of its location at any point in time and read or write anything.

This means that the system BIOS and the operating system can be overwritten easily, if there is lack of proper knowledge and management, by a program in the real mode.

Apart from that, it may also trigger an interrupt in the physical hardware and even send a signal accidentally to the peripheral device.

All these will have some serious adverse effects such as:

The mode is also characterized as follows:

In this specific mode, the RAM that can be accessed by a program is usually not buffered or managed by software, hardware, or the Basic Input Output System (BIOS) in any way.

This allows a program to access all reachable memory addresses irrespective of what purpose it is being used for.

Apart from that, it also means that every aspect of reading and writing to the memory should be managed by itself.

Before the protected mode was designed, the real mode was also used by several operating systems apart from the processors.

However, there is one specific aspect of this mode that is worth mentioning.

This operating mode restricts the use of RAM instructions by the processors to 16 bits and at least 1 MB of Random Access Memory in 20-bit address lines.

This is because in real mode the processor only supports addresses that are 20 bits in length.

This means that the processor can use only a part of the resources available in the computer.

Real addressing mode is also quite risky in the sense that it uses assembly language to write a program and executes it under a particular Disk Operating System (DOS), which normally does not switch to protected mode automatically during startup.

How Many Registers are Used in Real Mode?

Typically, there are four separate segment registers in the 8088, 8086, and 80286 processors that hold the segment addresses.

On the other hand, the 386 CPU and the later models have six of them in real mode. These processors and the later Intel x86 models still use segment registers of 16-bit size.

Read Also:  What is Pin Grid Array (PGA)? (Explained)

Ideally, the segment address of a memory location should be present in one of the registers irrespective of how this specific location of the memory is accessed.

These six segment registers are named differently and serve different purposes. These are:

The other two additional segment registers are named FS and GS, which are just clones of the Extra Segment or ES, and their nomenclature follows the order E, F, G.

There is no specialty in these registers that exists only in the 386 processors and the later x86 CPUs and are used for both data and codes.

There are also General Purpose Registers or GPRs that may contain data values as well as offset addresses.

These addresses may be paired with the segment addresses for locating data in the memory.

Can You Use 32 Bit Registers in Real Mode?

Yes, you can use 32-bit registers in real mode though it is a fact that when a processor boots, immediately after that it operates in real mode with its default to 16-bit code.

Still, this does not mean that you cannot use 32-bit instructions. Ideally, starting with the 80386, real-mode programs can use the 32-bit registers using the Address Size Override Prefix.

This override prefix of the size of an operand uses an address like the data segment, 66h.

This helps change the default mode of the single instruction by switching it to 32 bits when it is being executed in the 16-bit real mode.

On the other hand, when you use this override prefix with an instruction that is being executed in the 32-bit protected mode, it will switch the instruction to 16 bits as well, using a similar prefix, 67h, to override the sizes of the addresses.

Ideally, this prefix is emitted by the assembler automatically and almost certainly when you want to use a 32-bit operand with any instruction while assembling a 16-bit code.

This will allow you to use the 32-bit registers in 16-bit real mode.

However, if you wish to use a 64-bit instruction, you will not because there is no such override prefix available for it to be used in the real mode.

In that case, if you want to allow them, you will have to essentially switch to long mode.

However, when you try to do this or something similar to it, you must keep in mind that it is the instruction size prefix that allows the 32-bit instruction set, which is incompatible with the 16-bit, to work efficiently.

Typically, a 16-bit instruction set does not really care whether you are in the real mode or in the protected mode if you are not engaged with doing some segment arithmetic.

In that case, you will need to handle coding the 32-bit operations by using emit because the compiler will typically not generate them.

Virtual Real Mode

Virtual real mode is also known as V86 or 8086 mode. This specific mode allows the Intel 386 CPUs and the later models to hold a real mode 16-bit setting in the protected mode.

Read Also:  What is 3rd Generation Processor? Benefits & Drawbacks

However, when a computer runs in the virtual real mode, it can access memory up to 1 MB, as it can in the original real mode.

Ideally, an example of a computer running in this specific mode is when you open a Windows command-line window in the Microsoft Windows 98 operating system.

Virtual real mode typically refers to the third mode in which a processor can operate.

This specific mode of operation is simply an enhanced version of the protected mode, which comes with additional capabilities.

Typically, when you work with any particular graphic multitasking operating system like any one of the different versions of Windows, you will need to run it in the protected mode.

However, you may want to run DOS programs as well in it, but then, DOS programs typically run in the real mode rather in the protected mode.

When you use virtual real mode, this problem will be resolved. This is because it will imitate real mode in the protected mode. This will allow running the DOS programs.

In fact, there can be several machines in virtual real mode that can be created by a protected mode operating system like Windows.

It actually creates an illusion for the software running each of these machines which thinks that it is the only software running on it.

However, the benefit of using a virtual real mode is that each of the virtual machines has its own address space of 1 MB, an image of the actual hardware, Basic Input Output System routines, and more.

Ideally, when you run a DOS-based game or open a DOS box in the Windows 95 operating system, you are actually using it in virtual real mode.

When you start any such application in DOS, the operating system automatically creates a virtual DOS machine to run the DOS application on it.

Ideally, the virtual real mode was initiated with the 386 family of CPUs.

How Do You Switch to Real Mode?

You can switch from protected mode to real mode by creating a special program called the Ring 0 program. When you place this in the physical memory address, you can access real mode.

Here are the steps that you should follow to complete the entire process.

Now you can continue working in real mode using all of the BIOS interrupts.

What is Real Mode Interrupt?

Real mode interrupt is an alternative to polling supported by the processors. Here, the CPU determines whether the interrupt is active or not after every instruction is executed.

This is checked by the following conditions, in the specific order:

If it is found that one or more of the above conditions exist, then the processor will ensure the following:

Real Mode vs Protected Mode

What is the Use of Real Mode?

The most significant use of real mode of operation is that it enables the newer processors starting from the Intel 286 variants to run other older versions of software using the attributes of the lower processors.

Do All Processors Go into Real Mode?

The processors that are built on the original 8086 architecture typically start in real mode, which allows them to run programs written for earlier hardware.

However, this will need the software simulation to be successful.

Conclusion

Real mode, or real addressing mode, is quite useful for the processors to use in order to run older software programs.

Most aspects of this specific mode actually handle those particular issues that are generally seen in those applications that are written in assembly language. This is due to their relatively atomic nature.