Why codes can run well on Bochs,but it can't run on pure DOS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
leetow2003
Member
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

Post 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?
User avatar
thepowersgang
Member
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

Post 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?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Yargh
Member
Member
Posts: 56
Joined: Sat Jun 12, 2010 9:04 pm
Location: Somewhere else.

Re: Why codes can run well on Bochs,but it can't run on pure

Post 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...
Wait... What?
User avatar
thepowersgang
Member
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

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Owen
Member
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

Post 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...
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: Why codes can run well on Bochs,but it can't run on pure

Post by quanganht »

My best suggestion is get rid of DOS and boot off from bare metal.
"Programmers are tools for converting caffeine into code."
User avatar
Love4Boobies
Member
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

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Owen
Member
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

Post 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
Yargh
Member
Member
Posts: 56
Joined: Sat Jun 12, 2010 9:04 pm
Location: Somewhere else.

Re: Why codes can run well on Bochs,but it can't run on pure

Post 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.
Wait... What?
User avatar
Combuster
Member
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

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Love4Boobies
Member
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

Post by Love4Boobies »

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 ]
Post Reply