Setting up MSVC++

Feedback? Questions? Comments? All discussions on the articles and tutorials hosted or developed by us go in here.

Moderator:Moderators

Post Reply
michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am
Setting up MSVC++

Post by michael » Fri Jan 18, 2008 12:14 am

Oh while im typing this just a quick (unimportant)note but when using tabbed browsing withon your site I have to keep logging in but, anyway..

Well this is about the "Operating Systems Development - Setting up MSVC++ 2005" tutorial.. I downloaded the demo and tried compiling it on Visual C++ 2005 and it worked.. I copied the new stage2 bootloader onto my disk (It already had the 1st stage one).. And it doesnt load the 3rd stage properly :cry: just reboots.. Am I doing something wrong?.. I know my test machine should be okay I mean its new-ish, x86 and can run XP quite well lol... Ooh and everythings worked uptill now when I try and add c++ into it..

Ive tried countless hours of fiddling but still no luck hmmm.. so yeah.. anyone know what to do lol..

Thanks :D :)

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sat Jan 19, 2008 2:17 am

Hey,
I downloaded the demo and tried compiling it on Visual C++ 2005 and it worked.
Thats great to hear :)
I copied the new stage2 bootloader onto my disk (It already had the 1st stage one).. And it doesnt load the 3rd stage properly :( just reboots..
Can you please elaborate on what you mean by "new stage2 bootloader"? Also, what "disk"? Floppy disk? A file on your hard drive?

Does it work with your new stage2 bootloader running in Bochs? Or does it reboot ("Triple Fault") in both Bochs and your test computer?
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 2:27 am

By the new 2nd stage bootloader I mean i ran Demo5\SysBoot\Stage2\build.bat and it worked.. Cuz I noted you had changed Stage2.asm etc..

By disk I mean my great new usb floppy drive =D.. which took forever to order in and then it didnt even go :evil: but thats a different story.. but it works now :D

Umm Ive never gotten Bochs to work on Vista and its all I can get running at the moment...

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sat Jan 19, 2008 2:38 am

but it works now :D
...Did you manage to get it working? o.0
Umm Ive never gotten Bochs to work on Vista and its all I can get running at the moment...
There is a newer version of Bochs then that listed in the series. I am going to have to see if it is Vista compatible..

You can use other emulators (QEMU is nice) if you cannot get Bochs to work.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 2:45 am

Yeah I got my floppy drive working.. well got a replacement lol.. Itll write all the tutorials that only use nasm and my test machine will boot them all fine.

Just when I boot with the c++ tutorial it loads stage2, prints "Searching for Operating System..." to the screen and then triple faults..

Oh okay.. ill go have a look at them.. I dont really get what point having an emulator is though when ive got the real thing next to me and it takes like 30 seconds to copy onto a disk, boot, and stuff..

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sat Jan 19, 2008 3:07 am

Oh okay.. ill go have a look at them.. I dont really get what point having an emulator is though when ive got the real thing next to me and it takes like 30 seconds to copy onto a disk, boot, and stuff..
Running this in an emulator is much safer then real hardware. Please see <a href="http://www.brokenthorn.com/Resources/OS ... ">Tutorial 9</a>, Under the section <b>Cautions to look for</b> for more information.

Also, emulators (Like Bochs) may come with debuggers to help catch these problems :)
ust when I boot with the c++ tutorial it loads stage2, prints "Searching for Operating System..." to the screen and then triple faults..
Hm... It sounds like there is a problem loading the kernel, or executing it. When you compile the MSVC++ Kernel, have it output a linker map. This way we can insure the entry point is where it should be, as well as other base addresses.

^This is the only difference between the two tutorials. As the previous version works, I suspect the problem is one of these areas.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 3:34 am

Yeah I know about that.. Though if my computer breaks ive got like 15 more capable of runinng this stuff lol..

Oh but debuggers that sounds usefull :) I hadent realized..

I checked and that was allready set :? I tried compiling exacally with the settings I downloaded it as and it worked.. Oh I had to comment out one line, which I thought was useless?,or it wouldnt work though..

In the file asm\io.cpp it had the line

Code: Select all

 #include <asm> 
And I checked and ALL of the settings in the tutorial you said to do have been done..

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 3:41 am

Oh and if this is any help?

1>------ Build started: Project: Kernel, Configuration: Debug Win32 ------
1>Compiling...
1>io.cpp
1>mainCRTstartup.cpp
1>cstd.cpp
1>Main.cpp
1>Generating Code...
1>c:\users\michael\os dev\c++\syscore\lib\cstd.cpp(144) : warning C4702: unreachable code
1>Linking...
1>LINK : warning LNK4216: Exported entry point _mainCRTStartup
1> Creating library A:\KRNL.lib and object A:\KRNL.exp
1>A:\KRNL.dll : warning LNK4086: entrypoint '_mainCRTStartup' is not __stdcall with 12 bytes of arguments; image may not run
1>cstd.obj : warning LNK4254: section '.CRT' (40000040) merged into '.data' (C0000040) with different attributes
1>Order.txt : warning LNK4037: '_kmain' does not exist; ignored
1>LINK : warning LNK4096: /BASE value '0x100000' is invalid for Windows 95 and Windows 98; image may not run
1>Build log was saved at "file://c:\Users\Michael\OS DEV\c++\SysCore\Kernel\Debug\BuildLog.htm"
1>Kernel - 0 error(s), 6 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sat Jan 19, 2008 3:56 am

When you build your MSVC++ Kernel, The linker map should output to Demo5/SysCore/Kernel/Kernel.map - would you mind posting that for us?

Also, you do not need to worry about those warnings.

*Demo5 uses the same file and floppy code as Demo 4. Because Demo4 works fine (I assume), we know the file loading code is working fine. I am suspecting it is the MSVC++ image, but need to make sure.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 4:18 am

Oooh Demo4.. hmm.. Idk if ive ever gotten that to work.. To be honest I actully forgot about it lol..

No Demo4 does not work on mytest computer, it does exacally the same thing :o ..So that means c++ is working fine and its Stage2 thats the problem I guess?..

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sat Jan 19, 2008 4:44 am

Hmm... Have you tried it on different computers to see what happens? Is your test machine a PC or laptop?
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 5:45 am

Hmm theyre all in storage.. wait there is one I could try tho... :( cuz im moving house lol... Um its a pc...

Oh but I think Ive found the problem now.. I modified Stage2 to dump the first few hundrend bytes starting at 1MB onto the screen and it turns out its not the kernal wich I found there at all.... it was the stage2 loader :? I have no idea what thats doing there tho.. maybe it loaded the wrong file or something?

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sat Jan 19, 2008 6:03 pm

That is interesting. Perhaps stage2 is loading itself?

Insure Stage 2 is loading KRNL.DLL to 0x100000 (1MB) (or 0xffff:0x10 in seg:offset mode.) Or, in demo4, incure it is loading KRNL.SYS.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

michael
Posts:29
Joined:Thu Nov 15, 2007 12:06 am

Post by michael » Sat Jan 19, 2008 10:54 pm

Yeah thats all set up to do that... :shock:

Post Reply