Simplified ModRegRM Decoding
Before 80386 support was added to PCjs, the approach to decoding ModRegRM bytes (which I usually just call ModRM bytes) used one generated function per ModRM value. This was optimal for 16-bit processors, because the functions were small, and it was maximally efficient, turning the entire ModRM decoding operation into one table lookup and function call.
However, that approach didn't scale well for 32-bit processors, which had extended ModRM capabilities in both the addressing mode dimension and the operand size dimension. So I've rewritten ModRM decoding as 18 functions. The first 9 are for 16-bit addressing modes, and the second 9 are for 32-bit addressing modes. Within each group of 9, there are 3 for 8-bit operands, 3 for 16-bit operands, and 3 for 32-bit operands. And each group of 3 contains functions for register-source, memory-source, and group-source.
Each of the 18 functions must do additional work to examine the ModRM bits, which makes decoding slightly slower, but it's not really noticeable, and the speed difference didn't justify the additional generated code. So one much smaller file (x86mods.js) replaces a host of other files (x86modb.js, x86modw.js, x86modb16.js, x86modw16.js, x86modb32.js, x86modw32.js, and x86modsib.js).
Aside from all that work for absolutely no feature benefit, a few minor new features did slip into this release as well:
- Automatically removing the diskette "Save" button on mobile devices
- Giving auto-starting machines focus, so that you can immediately begin typing into them
Also, since the last release, I've added several new demos to the Home page, most notably:
- Windows 3.0 (running on an 80286 in protected-mode)
- Windows 3.1 (running on an 80286 in protected-mode)
- Windows 95 (running on an Compaq DeskPro 386)
As discussed in the latest blog post, these demos also run fairly well on mobile devices, too -- iPads and iPhones at least. There are still some issues, but those will hopefully be resolved in the near future, with the addition of PCjs custom soft keyboards.