A reader recently wondered about the details of a documented but extremely obscure instruction, FRSTPM. This instruction is documented to exist on the Intel 80287XL math coprocessor, as well as the Intel M80287. The FRSTPM instruction was not present on the original 80287.
To understand what FRSTPM does, let’s first look at its older and definitely useful sibling, FSETPM. The original 8087 tracked a 20-bit linear address of floating-point instructions and operands, a side effect of how the 8087 interfaced with the 8086/8088.
While a 20-bit linear address is adequate in real mode (mostly—FP instructions in the high memory area just above 1M would cause trouble, although that was not available on the 8086), it is very unsuitable for protected mode. In theory Intel might have extended the linear address to 24 bits on the 80287, but that would still be no good. Unlike real-mode software, protected-mode code cannot trivially form a segmented address corresponding to an arbitrary linear address. The original segment and offset needs to be known.
Intel therefore redesigned the 80287 to be able to track the original segment and offset of floating-point instructions and operands. However, this functionality was to be used only in protected mode; in real mode, the 80287 behaves in a manner compatible with the 8087.
And that is where FSETPM comes in. Since the FPU does not have access to the 80286 MSW (Machine Status Word), and is not automatically informed when the MSW changes, system software has to execute the FSETPM instruction after switching the CPU to protected mode. This instruction informs the FPU that it should use the newer protected-mode format (with a segmented address) for saving and loading the FPU state.
Continue reading







