jeffpar / pcjs.v1

PCjs Machines 1.0 (archived)
https://github.com/jeffpar/pcjs.org
GNU General Public License v3.0
475 stars 92 forks source link

386 SS has wrong behavior after reset #38

Open Octocontrabass opened 8 years ago

Octocontrabass commented 8 years ago

When the 386 is reset, the SS register has a value of 0 but SS behaves as if its base is nonzero. On a real 386, SS.base is set to 0 after reset. (...As far as I know. It does point to RAM, but I haven't verified exactly where.) Actually, upon further investigation, I think the issue is actually that SS is a 32-bit segment after reset, because stack operations are updating ESP instead of SP.

The code that tripped this bug reset the CPU using the keyboard controller, like below. I haven't tested what happens if the CPU is reset any other way.

MOV AL, 0xFE
OUT 0x64, AL

I found the bug while I was using this machine in Firefox on Windows.

Let me know if you need anything else.

jeffpar commented 8 years ago

Will do. What you suggest sounds plausible, but it'll require some debugging, because just looking at the resetRegs() code path, I don't see the problem yet.