LOADALL is the common name for two different, undocumented machine instructions of Intel 80286 and Intel 80386 processors, which allow access to areas of the internal processor state that are normally outside of the IA-32API scope, like descriptor cache registers. The LOADALL for 286 processors is encoded 0Fh 05h,[1] while the LOADALL for 386 processors is 0Fh 07h.[2]
Both variants – as the name implies – load all CPU internal registers in one operation. LOADALL had the unique ability to set up the visible part of the segment registers (selector) independently of their corresponding cached part, allowing the programmer to bring the CPU into states not otherwise allowed by the official programming model.
Another interesting usage of LOADALL, laid out in the book The Design of OS/2,[9] would have been to allow running former real-mode programs in 16-bit protected mode, as utilized by Digital Research's Concurrent DOS 286 since 1985,[10][11][12] as well as FlexOS 286[13] and IBM 4680 OS[14][15] since 1986. Marking all the descriptor caches in the GDT and LDTs "not present" would allow the operating system to trap segment-register reloads, as well as attempts at performing real-mode–specific "segment arithmetic" and emulate the desired behavior by updating the segment descriptors (LOADALL again). This "8086 emulation mode" for the 80286 was, however, too slow to be practical. The idea had to be mostly discarded due to errata in some early Intel 80286 processors before the E-2 stepping.[10][11][13] As a result, OS/2 1.x – and Windows in "standard" mode as well – had to run DOS programs in real mode. Nevertheless, the idea was not lost; it led Intel to introduce the virtual 8086 mode of the 80386, allowing the implementation of "DOS boxes" at last in a relatively efficient and documented way.
Because LOADALL did not perform any checks on the validity of the data loaded into processor registers, it was possible to load a processor state that could not be normally entered, such as using real mode (PE=0) together with paging (PG=1) on 386-class CPUs.[2]
An in-circuit emulator (ICE) is a tool used for low-level debugging. On Intel 80386, asserting the undocumented pin at location B6 causes the microprocessor to halt execution and enter ICE mode. The microprocessor saves its entire state to an area of memory isolated from normal system memory. The layout of this area is suitable for the LOADALL instruction, and this instruction is used by ICE code to return to normal execution.
In later processors, this evolved into System Management Mode (SMM). In SMM, the RSM instruction is used to load a full CPU state from a memory area. The layout of this memory area is similar to one used by the LOADALL instruction.[16] 386-style LOADALL instruction can be executed on 486 too, but only in SMM mode. In later processors, the RSM instruction, with a different encoding, took its role.
Microsoft's Codeview 3.0 and Borland's Turbo Debugger 2.0 correctly decode 286 and 386 LOADALL instructions.[1]
As the two LOADALL instructions were never documented and do not exist on later processors, the opcodes were reused in the AMD64 architecture.[17] The opcode for the 286 LOADALL instruction, 0F05, became the AMD64 instruction SYSCALL; the 386 LOADALL instruction, 0F07, became the SYSRET instruction. These definitions were implemented even on Intel CPUs with the introduction of the Intel 64 implementation of AMD64.[18]
80286
Opcode 0F05. The instruction reads data from addresses 0x00800–0x00866, whatever the content of the segment registers.
The 80286 LOADALL instruction can not be used to switch from protected back to real mode[19] (it can't clear the PE bit in the MSW). However, use of the LOADALL instruction can avoid the need to switch to protected mode altogether.
80386
Opcode 0F07. The instruction loads data from address ES:EDI. It actually uses ES, not the ES descriptor.
^Collins, Robert R. (October 1991). "The LOADALL Instruction". TECH Specialist - the Journal for Advanced PC Developers. 2 (10). Lawrence, Kansas, USA: R&D Publications, Inc. ISSN1049-913X. Archived from the original on 2020-02-20. Retrieved 2018-10-17. [5] (NB. The magazine was soon renamed into "The DOS Developers Journal" and eventually into "The Windows/DOS Developer's Journal" (ISSN 1059-2407).)
Juffa, Norbert; Siering, Peter (1990). "Wege über die Mauer. Loadall - Extended Memory im Real Mode des 80286". c't - magazin für computertechnik (in German). Vol. 1990, no. 11. pp. 362–366.