Subject: Re: Memory gets corrupted after reset Date: Tue, 24 Mar 1998 16:03:12 GMT From: Bob Smith Organization: Qualitas, Inc. Newsgroups: comp.lang.asm.x86 Likely what's happening is that at the time you execute the reset code, the A20 line has already been forced to zero so as to emulate the 1MB wrap. Normally, on reset, the next step the CPU takes is to fetch instructions from F000:FFF0 with the twelve high-order bits in the address set to 1 in the invisible descriptor cache. That is, the linear address from which the fetch should come is FFFFFFF0 (=4GB - 16) which is where the system ROM is located. However, because the A20 line has been artificially pulled down, the fetch actually comes from FFEFFFF0 (=4GB - 1MB - 16) at which location there is unlikely to be any physical memory present. This means that the CPU fetches bytes of FF FF ... (depending upon how the lines on the memory bus float) which is an invalid instruction, hence the INT 06h. For more details, see the article I wrote many years ago (along with an accompanying program, source code and all) in http://www.sudleyplace.com/ftp/386id.zip Thus, the solution to your problem is to disable the A20 wrap before resetting the CPU. If you have an XMS manager in the system, use that API, otherwise you'll have to write to the 8042 yourself. Chia Tee-Kiah wrote: > > Hi. > > While I was experimenting with my PC, I discovered that whenever I did a > software reset in real mode (no V86) using > > mov al,0xfe > out 0x64,al > jmp $ > > the processor would set ss = sp = 0, cs:ip = 0xf000:0xfff0, and generate an > exception 6. The exception 6 generation causes eflags, cs and ip to be pushed > on the stack, leading to memory corruption around the area > 0x0000:0xfff0-0x0000:0xffff. > > Is there a way to avoid this memory corruption, short of copying the memory in > the corrupted region to a safe place temporarily? (If I'm not wrong, doing a > reset in this manner is the only way to return from protected mode to real mode > on a 286.) ----------------------------- Bob Smith -- bsmith@sudleyplacedespam.com a.k.a. bsmith@qualitasdespam.com I've been getting a lot of junk e-mail lately, so to reply to me directly, delete "despam".