nepx / halfix

x86 PC emulator that runs both natively and in the browser, via WebAssembly
https://nepx.github.io/halfix-demo/
GNU General Public License v3.0
669 stars 86 forks source link

Another corner case shift issue #8

Closed DCNick3 closed 4 years ago

DCNick3 commented 4 years ago

The following snippet

stc
mov $0x00, %al
rcr $0x20, %al

sets al to 0x8, while 0 is expected, as x86 masks the shift count with 0x1f before the rotate.

nepx commented 4 years ago

Thanks for the report. I believe it should be fixed now.

DCNick3 commented 4 years ago

I believe the 32-bit shift should be changed to just & 0x1f, as per intel's pseudocode. Screenshot_20200724_104354

nepx commented 4 years ago

It should be fixed now, thanks for letting me know.

By the way, how are you finding all these corner-case shift bugs?

DCNick3 commented 4 years ago

I'm doing my own implementation of JIT-based x86 emulator. To make it easier to develop I fuzz it using (a bit patched) halfix implementation and compare results. Most times the fault is mine, but sometimes I find bugs in halfix =)

nepx commented 4 years ago

That's really cool, I'm planning on adding a JIT compiler too, I hope to see your project soon!