![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#4 |
|
Programmer
|
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"; |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
I wanna start learning ASM, but there's so much crap to do first. First on the agenda is C#.
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
I want to start learning ASM, but then i realise how much quicker it would be to write it in C.
__________________
|
|
|
|
|
|
#7 | ||
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Quote:
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:
<!--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?
__________________
"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 |
||
|
|
|
|
|
#8 |
|
Programmer
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 4
![]() |
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! |
|
|
|
|
|
#9 | |
|
Programming Guru
![]() |
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.
__________________
|
|
|
|
|
|
|
#10 |
|
Newbie
Join Date: Jan 2005
Posts: 4
Rep Power: 0
![]() |
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 ? |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|