Info-IBMPC@USC-ISIB.ARPA (09/28/84)
From: Info-IBMPC Digest <Info-IBMPC@USC-ISIB.ARPA> Date: 21 Sep 1984 0948-pst From: Robert A. Lerche <XA.W51%STANFORD.BITNET@Berkeley> To: <info-ibmpc@usc-isib.ARPA> Subject: Bug in '78 8088 An important note for anyone who changes stacks in the 8088: An early version of the 8088 chip has a bug that can cause memory clobbers. According to the Intel iAPX86/88 book, interrupts are disabled for one instruction following a MOV into a segment register. Thus, the safe way to switch stacks is to do a MOV into the stack segment register followed immediately by a MOV into the stack pointer register. The bug is that in 8088 chips marked "copyright 1978" the automatic interrupt disable DOES NOT OCCUR. Thus, if an interrupt occurs between the two MOV instructions, the interrupt routine will store the registers in the new stack segment but with the old stack pointer. Potential disaster! The fix, of course, is to do your own CLI before switching stacks. DOS 2.0 device drivers are entered enabled for interrupts, so this exposure exists there. Since timer interrupts occur 18.2 times per second in the PC, there's a good chance of a crash if you change stacks in your driver without disabling interrupts yourself. Take the word of one who has been burned. (P. S. remember to re-enable interrupts after you're done, or your clock may run slow.) There was an article about this in an early issue of the PC Tech Journal. In that article, they gave a test which involved using the debugger to trace a "move into segment register" instruction followed by an "INC AX" (if I recall correctly). If the "INC AX" executes (you can tell by examining the registers afterward) then you have a later-model 8088. If the "INC AX" does not execute, the trap interrupt occurred immediately after the "MOV", indicating you have a '78 8088. This bug was hell until I read that PC Tech Journal article. I wrote IBM a letter complaining and got a very nice phone call from someone who apologized and asked if everything was OK now that I knew the fix. He also said they would consider putting a note in the next version of the DOS manual, since the section on device drivers makes such a big point of saying you should allocate your own stack if you do anything other than saving the registers on the stack your driver is entered with. -------