Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 30th, 2004, 12:37 PM   #1
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I've been messing around with trying to make a few trivial programs that can run without an OS, just for the fun of it. I want to make a full-fledged OS sometime, and I'm just trying to get the feel for how things are done. Anyway, I wrote a simple program with NASM under dos that simply echoes back to you whatever you type. I ran it under DOS to test, and it works exactly how I want it to. Once I knew it worked, I wrote a simple program to load my "echo" code when the computer starts up. Now, my loader program definitely works on startup, as I have made it show me a simple message saying that it was loaded. The problem is that it doesn't load my echo program.

Now, I used debug to save my echo program to sector 5 of a floppy disk. This is the command I gave:

-w 100 0 4 1

Just to make sure I also did this:

-w 100 0 5 1
-w 100 0 6 1

I put my bootloader at the first sector, as I was supposed to using the same method. Here's the code in my loader that I'm using to load my code:

mov ax, 0x0201
mov cx, 0x0005
xor dx, dx
mov bx, 0x5000
mov es, bx
mov bx, 0x100
int 0x13
jmp 0x5000:0x100

All that is supposed to do is load the code from the fifth sector of my floppy disk to addred 0x5000:0x100. It's not doing that. I have no idea why. Have I written the jmp command incorrectly? I know for a fact that my code is there in the fifth sector of the floppy, as I checked with debug. Is there something I'm supposed to add in my echo program to allow it to act as a standalone program that I don't need in dos? Perhaps I need to set some segment registers or something? Could anyone help me out with what I'm doing wrong? Thanks for your time and any help I recieve.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Dec 30th, 2004, 8:19 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I tried to run the same code, except instead of using the loader as a standalone program, I used it to just load the program off of floppy running under dos, and it worked. So, obviously, there's nothing wrong with the loader. Is there something I need to do with my echo program before it works?
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Dec 30th, 2004, 9:15 PM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Well, I got it to work finally. I had to set the stack and data segments.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Dec 31st, 2004, 7:02 AM   #4
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
Bravo, dude. This is pretty much what I'm planning on doing when I decide to sit down and try. Except I'm going to use GRUB to load my code.

Isn't low level coding just so much fun?! I don't see why more people aren't interested in it. :blink:
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Old Dec 31st, 2004, 7:22 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8 Ooble is on a distinguished road
I wanna start learning ASM, but there's so much crap to do first. First on the agenda is C#.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 31st, 2004, 3:05 PM   #6
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
I want to start learning ASM, but then i realise how much quicker it would be to write it in C.
__________________

tempest is offline   Reply With Quote
Old Dec 31st, 2004, 6:52 PM   #7
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Quote:
Originally posted by Lance+Dec 31 2004, 01:02 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Lance @ Dec 31 2004, 01:02 PM)</td></tr><tr><td id='QUOTE'> Bravo, dude. This is pretty much what I'm planning on doing when I decide to sit down and try. Except I'm going to use GRUB to load my code.

Isn't low level coding just so much fun?! I don't see why more people aren't interested in it. :blink: [/b]

Thanks, man. I agree with you wholeheartedly. It is pretty fun. The only reason I wrote my own loader was to find out how everything works. It's a cool feeling knowing that your code is the (more or less) only code running on a machine, even if it's not very sophisticated.

Quote:
Originally posted by Ooble@
I wanna start learning ASM, but there's so much crap to do first. First on the agenda is C#.
I know what you mean. There's so much I want to learn, I just decided before I went on with anything else, I was going to teach myself some low-level stuff. I have like a long-term plan, actually. I'm going to read this book by Tanenbaum called Operating Systems: Design and Implementation. Then, I'm going to decide whether I want to try and make a full-fledged OS or not, although if I read that whole book, I had better still want to make a full OS. I'm not even going to try to distribute it at all, I'm just going to do it to learn. I'm also going to try and learn more about the Linux kernel. After that I want to learn Perl. It used to be Python, but then I went to rentacoder.com, and saw so many Perl jobs for people, I was like, okay, this is what I want to do. It just seems a little more practical to learn Perl, despite whichever is the better language. That's really one of the problems I have. I learn a lot of stuff out of interest, but don't know how much I'm going to be able to apply it in real-world situations. Then, I want to learn AI, as that was my father's line, and he could teach me a lot about it. It seems cool as well. That should take a good couple of years to get through with at the very least.

<!--QuoteBegin-Tempest

I want to start learning ASM, but then i realise how much quicker it would be to write it in C.[/quote]

Yea, but even in C you can't quite do all the low-level stuff that you can in ASM, can you?
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Dec 31st, 2004, 7:51 PM   #8
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 4 Ravilj is on a distinguished road
My ASM days ended when I stopped programming in mode 13h and when pascal sort of became obselete though I fondly remember it. But as Ooble pointed out there is so much to learn and so little time. I think for me I will delve into ASM again if the need were to arise.
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Jan 1st, 2005, 12:35 PM   #9
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Quote:
Originally posted by Mjordan2nd+Jan 1 2005, 12:52 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Mjordan2nd @ Jan 1 2005, 12:52 AM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Tempest
I want to start learning ASM, but then i realise how much quicker it would be to write it in C.
Yea, but even in C you can't quite do all the low-level stuff that you can in ASM, can you? [/b][/quote]
C is just alanguage that's only purpose is to be broken down into ASM by the compiler. Its a way to write ASM. I've never tried it but im sure with malloc and such you could replicate any ASM program in C.
__________________

tempest is offline   Reply With Quote
Old Jan 4th, 2005, 3:35 AM   #10
SubhadeepGhosh
Newbie
 
Join Date: Jan 2005
Posts: 4
Rep Power: 0 SubhadeepGhosh is on a distinguished road
Hey,
I've got a small doubt about you loading and running a program without the use of an OS.
The frst thing is that, as far as I knew, when you compile or assemble a code under any OS...the OS places an OS specific header in your program (which is one of the reasons why you cannot run a code compiled in one OS, in another OS)...now if an OS specific header exists in your executable, then your code will not execute without the OS.
The second thing which I wanted to know was that, arn't you supposed to initialize the procesor and the memory before executing your code ?
SubhadeepGhosh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:54 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC