Date: Sun, 27 Feb 2000 10:28:39 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Lin cc: djgpp AT delorie DOT com Subject: Re: Problem on various DPMI host In-Reply-To: <38b87082.65742@netnews.hinet.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: dj-admin AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 27 Feb 2000, Lin wrote: > I can excute both code image on WIN95's DOS box without any problem. > it create a new file name RESLT.DAT ok. > but at plain DOS (both 7.0 and 6.22) both code will just show messup > code on screen. This is expected: your code calls Int 21h from protected mode: > mov edx,file_name > mov ah,3ch ; create the a file and get handle > mov cx,0 > int 21h This will *never* work in plain DOS, because you need to issue Int 21h in REAL MODE. The reason for this is that DOS is a real-mode operating system, so its code cannot run when the CPU is in protected mode. The reason it works on Windows is that Windows includes a built-in DOS extender, which catches Int 21h calls made from protected mode and does the necessary magic (described below) behind the scenes. But on DOS you need to do this yourself. There's a special function of Int 31h, the DPMI API interrupt, which was designed for this: it switches the CPU into real mode, reissues Int 21h, then switches the CPU back to protected mode. Note that you need to copy the file name and the data you want to write to the transfer buffer, because DOS cannot access memory above 1MB mark, where your protected-mode program runs. This is all explained in sections 18.1, 18.2 and 18.4 of the DJGPP FAQ list. I suggest to read it. Alternatively, you could call library functions _creat, _write, and _close, they do all this for you.