title: How to detect protected mode in a Volume Boot Record (Partition Boot Sector)?
body: <p>I am debugging an unusual booting arrangement in MBR mode (no EFI) on an x86 PC.<br>
  <code>IPL</code> in MBR --&gt; exotic <code>BootManager</code>* --&gt; <code>Partiton Boot Sector</code> --&gt; experimental <code>OS</code></p>
  <p>I wrote a primitive 512-byte Partition Boot Sector (PBR) in 16-bit real mode <code>x86</code> assembly, which uses the <code>int 10h</code> BIOS services to display the 16-bit registers which are passed to it.  It works well for debugging.</p>
  <p>I would like to enhance my debug PBR to also display info about the CPU mode, i.e. whether the BootManager has already switched the CPU into the <a href="https://en.wikipedia.org/wiki/Protected_mode" rel="nofollow noreferrer">Protected Mode</a> (32bit or 64bit) or its submode such as the <a href="https://en.wikipedia.org/wiki/Virtual_8086_mode" rel="nofollow noreferrer">Virtual 8086 mode</a>. I need this info for debugging purposes.</p>
  <p>How to reliably detect the <code>CPU mode</code> (and its subtype) in this scenario ?
  <br>
  <br></p>
  <ul>
  <li><em>The BootManger is located in the sectors between the MBR and the 1st partition and it intercepts/emulates BIOS services/interrupts - I have seen it pointing the <code>int 13h</code> vector to itself in a debugger</em></li>
  </ul>
  <p><em>EDIT:  This question is NOT about detecting the CPU mode of a CPU emulated in software. (a.k.a.: virtual CPU)<br>
  Also, <code>Virtual CPU</code> is not the same as the <code>Virtual 8086 mode</code> of a real CPU.  The <a href="https://en.wikipedia.org/wiki/Virtual_8086_mode" rel="nofollow noreferrer">Virtual 8086 mode</a> is a CPU mode, which is a submode of the <a href="https://en.wikipedia.org/wiki/Protected_mode" rel="nofollow noreferrer">Protected Mode</a> and it is implemented in HARDWARE so the detection of this submode IS the subject of this question, together with the detection of the 32-bit and 64-bit <a href="https://en.wikipedia.org/wiki/Protected_mode" rel="nofollow noreferrer">protected modes</a>, etc... implemented on real silicon</em>.</p>