Page 3 of 3 FirstFirst 123
Results 81 to 112 of 112

Thread: when to start writting my own os

  1. #81
    Addicted Member ChuckB's Avatar
    Join Date
    Jul 2002
    Location
    South Carolina, USA
    Posts
    157
    GuitarMan,

    Your bootsector explanation makes sense to me.

    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.

    Thanks. ChuckB

  2. #82
    New Member racing_fire's Avatar
    Join Date
    Jun 2002
    Location
    USA
    Posts
    13
    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.
    Another post by Kevin.

    Best viewed with common sense enabled.

  3. #83
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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.
    Attached Files Attached Files
    Designer/Programmer of the Comtech Operating System(CTOS)

  4. #84

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Off-topic...

    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 ax0x1000
    mov ds
    ax 
    Why can you do something like this (for NASM):
    PHP Code:
    mov axseg 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".
    Baaaaaaaaah

  5. #85
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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)

  6. #86

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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?
    Baaaaaaaaah

  7. #87
    I did not see the code, but however I think you should do

    mov si,message
    call PrintStartup
    mov si,message2
    call PrintStartup

    This is how it worked in my very basic OS, in ASM, but however its now in C.

  8. #88
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    !

    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


    mm

  9. #89
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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)

  10. #90

    Lightbulb

    You're copying what I said Naughty boy!

  11. #91

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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.
    Baaaaaaaaah

  12. #92
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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)

  13. #93
    I read some tutorials, and I knew He, with its very much better OS than mine, didn't even know LOL!

  14. #94
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  15. #95
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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?
    Attached Files Attached Files
    Designer/Programmer of the Comtech Operating System(CTOS)

  16. #96
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197
    mega-tokyo.com/forum
    retired member. Thanks for everything

  17. #97
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    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

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  18. #98
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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)

  19. #99
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    No apparent errors, I'll read about INT 13h tomorrow.
    Just one thing: it says you should reset floppies between read attempts.
    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.

  20. #100
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Have you tried reading out ah on return?
    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.

  21. #101
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Hey parskie,

    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?

  22. #102
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94
    Hey TechySpecy 0xLv6Tfl/AWwL+ZFnFx9IV0O81SaXnOT2ckdHfpsJ9
    XVkarZ2BC4hMdXQqFwvlhxn8S9cVXUCFGfxpQdTdRUbaCFeE9oc4f+El4OgZ19TFvfVAcc72arOh
    xYeTKX9WCXe+yHgbGHD8V5qj3fmuUmzCpH7Oz52rcrX22sQ8O5VLjYUgT7wCrsaZeoik4yPoBXo0
    zmhZ/CGiXaoF/fTTOcpdCWO9xzCjZxryIsEAykzuszAVWgFtoMe456KgVN6i3mDJ0rGOT+TC9fDX
    GUl3lG69QRKhxlF4fXGUkE3q7T4ppIz0490a/n9JQlKtz6ap8EjGd8ByoOBpZ09Rl43f5JO/bsYA
    GrDhohBx5D4QStqdn14mvfvqsfYrdhdn7pXhJcKIOLkWIkWbxoTJ5ioAaG/3wSsmHBn7XbELFiev
    nXUwj+b33DNP5mCoyB1AoKp+QVoECaURSTpmiNzCw+N2lwYiHy+gQTXTC9vLwwSOp4Wv9LoKbU3U
    PYwmbmxzZFVWZ4JnCp6cSF2toRE/EQPmU8KVmldlWfsGBuudYgaa/pjg5ah+NzNKXRVwBVbShNMl
    phCF8iLHbpQepSbtUIcnkNMNwWk86UzM/iI5yV+vO8ISZuok4vmw93y+CMsGzEhPtbNIOWPqNLAd
    nvN8/kDyFx7gzjOG4XXNoP2hA2MX6TPbuGIptSqBKHL8RzwkaRRVhsmPUR2LUhzmYdiVu5+5sRR5
    RFllTE7fS4S3GrHsuGuYJ/LUBb1aKzXxCrC9HKfX1reBmaVcqWoQVm+4Kr+1vevbOQ/0
    Last edited by pskyboy; Sep 10th, 2002 at 03:48 PM.

  23. #103
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    I need to learn ASM.

    What is the best way?

  24. #104

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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.
    Baaaaaaaaah

  25. #105
    Please note; art of assembly is for MASM

  26. #106
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There is a MASM version of AOA, but there also is a 16-bit version which doesn't use MASM.


    BTW what happened to pskyboy's post?
    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.

  27. #107
    Originally posted by CornedBee
    There is a MASM version of AOA, but there also is a 16-bit version which doesn't use MASM.


    BTW what happened to pskyboy's post?
    Maybe an attack of madness

  28. #108
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    And now the CTGUI!

    ...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)
    Attached Files Attached Files
    Designer/Programmer of the Comtech Operating System(CTOS)

  29. #109
    The space doesnt work, I cant move the window...

  30. #110
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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).
    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.

  31. #111
    Aaaah now it works, but it damned flickering..im getting mad of it..

  32. #112
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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)

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width