Page 1 of 1
Why codes can run well on Bochs,but it can't run on pure DOS
Posted: Sat May 21, 2011 6:19 pm
by leetow2003
I write codes about priviledge change,it can run well on Bochs,
but I find when it run on pure DOS,PC always restart,why?How
to avoid these error?
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sat May 21, 2011 7:54 pm
by thepowersgang
Please, read the forum rules, especially the link in part 4: Asking questions the smart way.
That said, .... no, there's no way we can help you without more information.
How is it restarting? where does it happen? Have you tried doing printf-spam?
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sat May 21, 2011 7:57 pm
by Yargh
Maybe cause you're writing code to run on the computer itself (not DOS), and then trying to run it under DOS? You DO know that you can't run another OS under DOS...
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sat May 21, 2011 8:07 pm
by thepowersgang
@Yargh: Actually, you can. DOS doesn't do any protection, hence you can quite nicely just boot a 32-bit OS off it.
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sat May 21, 2011 8:09 pm
by Owen
DOS itself doesn't. But if there is a running EMS, VCPI or DPMI server, then you won't be able to do a simple switch to protected mode...
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sat May 21, 2011 8:25 pm
by quanganht
My best suggestion is get rid of DOS and boot off from bare metal.
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sun May 22, 2011 1:09 am
by Love4Boobies
This may not be DOS-related but bare metal-relate. The number one cause for things that work under emulators but not bare metal is that the developer(s) assume(s) that memory has been magically zeroed out. Don't forget, you don't have an OS to do that for you before your code is loaded.
Owen wrote:DOS itself doesn't. But if there is a running EMS, VCPI or DPMI server, then you won't be able to do a simple switch to protected mode...
Well, EMS and XMS were both APIs for real mode so they work just fine. However, you can add XVCPI to the list.
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sun May 22, 2011 7:56 am
by Owen
The most common implementations of XMS and EMS (e.g. EMM386) are built using v8086 mode and paging - hence the need to use VCPI to get into protected mode
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Sun May 22, 2011 8:52 am
by Yargh
thepowersgang wrote:@Yargh: Actually, you can. DOS doesn't do any protection, hence you can quite nicely just boot a 32-bit OS off it.
By that I meant that DOS configures the hardware differently than the BIOS, and running code that expects itself to be run without the hardware configured would cause issues.
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Mon May 23, 2011 6:18 am
by Combuster
I also get the idea from the original post that DOS isn't the only difference, but that it's native in bochs vs dos on a real PC (he writes "PC restarts" rather than "bochs restarts"), In which case it's just as likely that its a real-virtual hardware difference instead of the presence of some software that barely cares about its own sanity.
Of course a bootsector won't just work properly under DOS anyway without modification.
Re: Why codes can run well on Bochs,but it can't run on pure
Posted: Mon May 23, 2011 10:51 am
by Love4Boobies
Yep, I've suggested that too but we seem to enjoy getting distracted about every little thing anyone says... everytime!