Background
I am trying to make a bootloader that would work for two architectures: x86 and PDP-11. The main OS is written for a PDP-11-compatible machine, but booting from x86 should work too, starting an emulator.
AFAIK, x86 loads the first disk sector to 0x7c00 and jumps there, if the last two bytes are 0x55 0xaa. In contrast, the PDP-11-compatible machine loads the first sector to 0o20000 (octal) and executes it if the first command is NOP and the last two bytes are 0xaa 0x55. However, due to some hardware details, the loaded data is actually inverted -- for example, where x86 would read 0x12, the other machine would read 0xed. This is somewhat a feature in this context because if I make the last two bytes 0x55 0xaa, they would work for both machines.
In conclusion, the PDP-11-compatible machine requires the first two bytes to contain NOP command, i.e. 0o000240, or 0x00a0. The data is inverted, so x86 would actually read 0xff5f instead.
Problem
0x5f is a real command in x86. Unfortunately, it's pop di. AFAIK, both sp and ss values are not specified, so this command reads who-knows-what.
My questions are:
- In practice, can I assume they either point at valid stack or are both set to some placeholder, e.g.
0x0000:0x0000or0xffff:0xffff? - May
ss:sppoint to memory-mapped hardware registers which are unsafe to read? If yes, what is the worse thing that can happen if I read them? I don't want to accidentally kill a laptop. - May
ss:sppoint to unavailable memory, i.e. maypop ditrigger a bus error? If yes, how will the BIOS recover from it, i.e. will it reboot, show a message or do something else?