Why codes can run well on Bochs,but it can't run on pure DOS
-
- Member
- Posts: 70
- Joined: Fri Nov 19, 2010 6:54 pm
Why codes can run well on Bochs,but it can't run on pure DOS
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?
but I find when it run on pure DOS,PC always restart,why?How
to avoid these error?
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Why codes can run well on Bochs,but it can't run on pure
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?
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?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: Why codes can run well on Bochs,but it can't run on pure
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...
Wait... What?
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Why codes can run well on Bochs,but it can't run on pure
@Yargh: Actually, you can. DOS doesn't do any protection, hence you can quite nicely just boot a 32-bit OS off it.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Why codes can run well on Bochs,but it can't run on pure
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
My best suggestion is get rid of DOS and boot off from bare metal.
"Programmers are tools for converting caffeine into code."
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Why codes can run well on Bochs,but it can't run on pure
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.
Well, EMS and XMS were both APIs for real mode so they work just fine. However, you can add XVCPI to the list.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...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Why codes can run well on Bochs,but it can't run on pure
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
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.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.
Wait... What?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Why codes can run well on Bochs,but it can't run on pure
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.
Of course a bootsector won't just work properly under DOS anyway without modification.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Why codes can run well on Bochs,but it can't run on pure
Yep, I've suggested that too but we seem to enjoy getting distracted about every little thing anyone says... everytime!
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]