Code Smells of Desperation (2023)
Web page · https://os2museum.com/wp/this-code-smells-of-desperation
First seen by Oriel on .
AI summary
An analysis of WIN87EM.DLL’s x87 exception handler argues that its convoluted delays, repeated latch clearing, and duplicate exception clearing resemble desperate fixes rather than deliberate design.
- WIN87EM.DLL appeared in Windows 3.0; its Windows 3.1 version changed little, and the Windows 3.11 copy is byte-for-byte identical.
- The library hooks NMI vector 2 on PC and PC/XT systems, or IRQ 13 on PC/AT-compatible systems, to intercept floating-point exceptions.
- Its IRQ 13 handler repeatedly pushes and pops AX, writes four times to I/O port F0h, and executes FNCLEX twice.
- The handler eventually saves the FPU environment, restores the earlier status word, examines instruction prefixes near the error pointer, and enters shared math-error handling code.
- The repeated operations may provide timing delays or accommodate broken hardware, but the author finds comparable handlers simpler and more consistent with documented practices.
#x87 #windows 3.1 #pc architecture #reverse engineering
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 14, latest observation ; +11 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 4, latest observation ; +4 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50465395 | https://www.os2museum.com/wp/this-code-smells-of-desperation/ Read discussion |