Writing an OS has always been one of those mystical things to me. I have done a lot of relearning of assembler and reading various tutorials and now it doesn't seem all too incredible. Sigh! However, I have never done this. I am a pretty decent programmer in VB and C but somehow feel inadequate until I write an OS. :-)
Now, I understand that when BIOS read the bootsector and runs the bootloader, it loads IO.SYS which contains all sorts of hardware functions (interrupts)...then MSDOS.SYS for higher functions...CONFIG.SYS, COMMAND.COM and then AUTOEXEC.BAT. Does that sound right?
My goal would be to write a very simple OS that boots up off of a floppy disk and then displays a command prompt that allows me to type in anything...and all it does is echo what I have typed. Nothing more. Is that too complex?
To implement I would write a bootloader in the boot sector (I think that is where the loader is located). I can then write another program to monitor the keyboard and print to monitor. I could do this with BIOS interrupts and no DOS interrupts. Would this then qualify as an OS?
Is an MSDOS formatted floppy disk sufficient or do I have to define my own format level? If this is okay then I guess I need to be able to read the FAT from the bootloader to pull up the second program I mention above. Is that correct?
Does a bootloader only qualify as an OS?
Sorry for the simple questions but I am trying to put together the big flick in my mind.
Goto Planet-Source-Code and search in C\C++. I've found some things, all of them have a bootstrap made in ASM and they use partcopy to put it in the first sector of a floppy.
Or, you could use this piece of code from my OS. It is a FAT12 boot sector that loads KERNEL.BIN from the floppy. It will search for the file until it finds it. If there is no kernel, it will tell you, then hang the system. I have included a simple kernel that displays a message and hangs.
ChuckB, you can use this minimal OS as a backbone for starting your OS. You don't need to change the boot file. To start off, download this file, then NASM. Extract the files from this zip some where. Format a floppy, then go into DOS prompt(in the folder) and type in "partcopy boot 0 200 -f0" to copy the boot file onto the floppy's boot sector. The partcopy numbers are all in hex. Edit kernel.asm and add what you need to so get input and then display it. Put it in a loop, then go to DOS and type "nasm kernel.asm". Rename kernel to kernel.bin, then copy the file to the root directory of the floppy. Shut off your PC, then turn it on with the floppy in the drive. Your OS should load(Whatever is in kernel.bin). Put out the disk when you are done and restart to get your windows back.
Designer/Programmer of the Comtech Operating System(CTOS)
I already asked this but got no response.
Warmaster, in your Kernel.asm file, it prints a message. I first moves the segment of your "startmessage" string to ax and then it moves it to ds (data segment). Here is how you're doing:
PHP Code:
mov ax, 0x1000
mov ds, ax
Why can you do something like this (for NASM):
PHP Code:
mov ax, seg startmessage
mov ds, ax
I already tried this sort of coding but NASM gives me an error on the line containing "seg". This works fine in TASM when I use "segment" instead of "seg".
I understand now what you're trying to say. There is an error in that because I had a start-up file that was supposed to be loaded and run inable to enable more than the 1MByte limit for the CTOS kernel to be loaded. The number should be 0x0050, not 0x1000. These are basically initializers to set the program's active segment. That are not needed for this particular KERNEL.ASM, but it is a good idea to have them for expansion. As soon as you declare a variable, the CPU will look in the previous segment. Therefore, you need to set an "active segment" (0x0050). The code to CALL the textprinter is just this:
mov si, message
call PrintStartup
Just make sure you have a string called message with a 0(NULL) as the last char(Be sure to have "PrintStartup" as well).
I hope that I have cleared this up
Designer/Programmer of the Comtech Operating System(CTOS)
Ok thanks, but how would you display another string? For example, if you declare another string called message2, how would you print it using its segment and offset?
is that code available here,or something like that
im asking this becouse u are talking about some function ,and i dont know how everybody know names of your func,or maybe it is available just for specified person
and thaks ABDUL ,ive learnt somthing useful things from your program HIDEWINDOW .im useing it right now
Originally posted by abdul Ok thanks, but how would you display another string? For example, if you declare another string called message2, how would you print it using its segment and offset?
You would say:
mov si, message2
call PrintStartup
...to print message2. Remember to have a NULL(0) at the end of each string or this will hang your PC.
mmiill, the code is available at my post on the top of this page.
Designer/Programmer of the Comtech Operating System(CTOS)
Thanks, I understand it now. I see you're using a different interrupt instead of 21h and function 9h. I was trying to use 9h before which requires the the address of the string to be placed at DSX. I tried so using nasm but it said that binary format doesn't support this type of segment reference. Also when I try to include an external .inc file and then compile it to a binary file, it gives me an error saying that binary format doesn't support reference to an external file.
Weird because TASM lets me do all this pretty easily.
Geez... It took about 7 minutes just to load this "Reply to topic" page. NEVER EVER get Bell Sympatico High speed DSL. They say it's fast all the time? What a load of BS...
Anyways...
Dan, I didn't realize that you had already posted. I should check everything first before posting an answer.
I am designing my start-up module, known as STARTUP.BIN - It's the file the boot sector loads. STARTUP.BIN will be able to:
- Read FAT12/16/32
- Set the display to 640x480x256 color VESA
- Set the A20 address line(enable more than 1MByte of RAM)
- Load a startup bitmap and CPU logo bitmaps (according to detected CPU)
- Load KERNEL.BIN and a pmode disk driver for IDE or SCSI
- Initialize the GLD, IDT, LDT, and 32-bit Protected Mode
- Jump to the kernel
This whole file should be completely assembler. Total file size should need less than 1 segment (64KBytes). The bitmaps are separate files. This is VERY do-able. It should be done in a few months(with just me coding it). The FAT code is done, except for opening files and directories(The FAT manip. fncs. are ready), and read_sectors(d,s,*b); The FAT code is all in C, but my compiler can generate ASM code from the C code (BorlandC v3.1)
Read_sectors(); is giving me one big hassel. I have tried last night and all of today to get my computer to read the first sector into the correct buffer address. This is necessary for the FAT code to work. The buffer is always off by about 100-300 bytes and I have no idea why. I am embedding ASM code in my C code, and I think I am not passing the buffer's address correctly. I am using Int13h to read, but maybe I should use Int25h instead. This stupid/simple read_sectors(); is really annoying me. This should be very simple - someone tell me how to do it!!! I will try using Int 25h. Tomarrow (thursday) is my last day on here for a while - gone for 3 days without a PC. I got to get me a laptop PC
Abdul, the reason I did not use Int 21h is because it's only supported by DOS. DOS installs that handler. Since we are making our own O.S.'es, we can't use that interrupt. Us people that are using Protected mode, We cannot call the BIOS while in Protected Mode (NO INTERRUPTS) except it we switch to V86 mode or back to real mode. Therefore, all loading of filesystem and disk drivers should be done BEFORE we enter protected mode or else we are stuck, lol (I found this out 2 days ago )
Designer/Programmer of the Comtech Operating System(CTOS)
warmaster, you could post the function here and so we can look for errors - I don't know much about OSs, but quite a lot about ASM and C, and cooperation of the two.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
I found that I can't use Int 25h because it's a DOS routine.
OK, here is the code. It's been brutally beaten and massacred, so I don't know if it's even a good start. It is possible that the error was just my BIOS on my old computer, but don't they ALL support Int 13h?
Designer/Programmer of the Comtech Operating System(CTOS)
I bet u need a fusion powered shuttle to reach my place...
Posts
963
FAT...
I found numerous FAT guides...
however, no way 4 me 2 understand it...
Pls anyone post codes on FAT, the foundation of FAT and creating
files and folders as well as managing them...
Compatible with MS-DOS...
Pls I need 2 know how...anyone?
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline
So I consider all those working engineers sad people
BY FAR the best document for describing FAT12/16/32 has to be this one. It tells you how to access each cluster based on the FAT table in the beginning of the drive, how to calculate the position of the table based on the boot sector, what the boot sector for a FAT system should look like... It's an amazing resource. I have used it for making my ALMOST complete FAT driver. All that's needed is a function to open/close files and directories. I could get that finished very soon.
Now, does anyone have a fix for my readsector problem? Or will I have to just go for assembler?
Designer/Programmer of the Comtech Operating System(CTOS)
I do not know what skill levels are required to do something like what you guys have talked about throughout this discussion, but i am well familiar with c,c++. Do not have any clue about ASM.
Can you guide me a little bit. Where should i start for learning ASM?
PC Assembly Programming does teach you Assembly language so follow the link that pskyboy posted or you can also read the book Art Of Assembly (very long...about 1500 pages). The good thing about PC Assembly Programming is that it also teaches you 32-bit programming (using 32-bit registers) and also puts in some C and tells you how to use Assembly in C and vise-versa.
...And now, here is my GUI(Window Manager) after working on it 7 days in school for an average of 30minutes a day during my programming class that I teach Grade 10's(I'm a peer tutor - I don't actually teach)
Currently, It (The Window Manager) can:
- Draw windows that have a border (that's it)
- Support up to 64 windows being active and up
- Support moving of windows
- Support switching of a window's z-order.
To use it, move the arrow key to move a little white dot(cursor). When over a window, press space to bring it to focus, then press space again to select it for moving. To release the window in the spot you want it, press space again. Press escape several times to quit... It does need to use double buffering to make it not flicker...
It is NOT complete, but this eventually WILL turn into my operating system's GUI! I am sorry, but I will NOT release source code
Updates to come when I get titlebars and window control boxes working(x, min, max)... and resizing...
(I just had to show you guys this)
Designer/Programmer of the Comtech Operating System(CTOS)
Works only for the three windows in the top right corner. The others don't react. (Don't even exist, they disappear once you bring any other window to the front).
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Originally posted by CornedBee Wheeeeeeeeeeeeeeee.
Works only for the three windows in the top right corner. The others don't react. (Don't even exist, they disappear once you bring any other window to the front).
I know... Those were the drawing routines drawing stuff... The bland, dark grey square is actually clipped. By the routine's definition, it should have taken up half the screen, BUT: I gave it a rect to clip to... It only draws in that rect... I only use 2 actual CLib functions: Getch(), and Int86(); All the rest(About 20-30) are created by me. The other shapes clear as soon as you select one of the 3 windows for moving. What I do right now(inefficient like crazy) is clear the screen and then call drawgui() which redraws all windows (and later, calls all functions that are in a window's struct [controls ])
I said that the WM supports 64 windows, but right now, I only created 3 windows. createwin(x,y,w,h,txt,type); is what I made the function (similar to windows - familiar to some). Createwin looks through all 64 windows and finds one which does not have the WMFLAGS_ACTIVE bit in window[handle].flags set. Once you understand how I did this, it's really quite amazing. That is only 500 lines of code... and it condenses to 8KBytes using PowerC compiler.
Email me if you want PowerC - fits on a floppy and runs off DOS in a command line...
The flickering WILL go away... when I optimize the code and get a double buffer added (which for some reason doesn't work )
Designer/Programmer of the Comtech Operating System(CTOS)