Thread: Operating systems written entirely in C/C++???

  1. #1
    stovellp
    Guest

    Operating systems written entirely in C/C++???

    Gidday,

    I'm starting to learn about operating systems, and have picked up a couple of good books about the subject. However, I'm about a quarter of the way into them, and I am wondering:

    How can an operating system be written entirely in C/C++ without a C++ Compiler for that operating system? Wouldn't you have to write the base stuff first in assembly?

    I myself know quite a bit C++ but hardly any assembly, I only know what most of the registers are for.

    Any help would be appreciated.

    Paul

    PS: Don't tell me to read a book, etc, because I am already doing that. I just wonder how this is possible.

  2. #2
    stovellp
    Guest
    Yeah I didn't think it could all be done in C either, but (I think) UNIX, Linux or Windows (Not sure which one) claim to be written entirely in C.

    So I guess this means I'll have to learn assembly. Fat chance, my computers running windows 2000 and cries when I try any assembly stuff.

    I'll have to go back to linux again.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by stovellp
    So I guess this means I'll have to learn assembly. Fat chance, my computers running windows 2000 and cries when I try any assembly stuff.

    I'll have to go back to linux again.
    That's probably because you are learning the wrong asm for the OS...if you are using DOS routines then you cant expect it to work 100% on a system that doesnt rely on DOS....the problem is that people stopped writting ASM books years ago.....you have to rely on old books, technical manuals (downloadable from both AMD and Intel - Intel even send out books for free, but only like twice a year and it took me ages to get mine) and the web...the last option is the best as you can find anythiong you want thriough google as long as you are patient enough

  4. #4
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Originally posted by Fordy
    the problem is that people stopped writting ASM books years ago.....you have to rely on old books, technical manuals
    Not entirely true... I've taken 2 assembly courses in the past 2 years and both books were fairly new. Granted, the one was more or less a manual for a microcontroller, but the other was a full assembly book written for straight assembly and for real-time systems.
    EntropySink. You know you have to click it.

  5. #5
    stovellp
    Guest
    What was the name of the book ober?

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    One of the best resources for assembly on intel machines is the 'Intel Trilogy' of manuals. In fact, I got so tired of waiting for them, that I just downloaded them from intel's site, and printed out all three volumes! Anyway, these manuals alone will prepare you for 75% of the assembly, the rest of which can only be learned by reading someone else's source, trying out stuff on an assembler, etc....
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    stovellp
    Guest
    What were the titles of those manuals Sebastiani? I've searched Intels site for Trilogy and assembly but theres so many matches I'm not sure which is the right one.

    I'm downloading the Intel Archetecture Software Developers Manual now, but I'm not sure thats the one you meant.

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    What you are downloading and what is in those books are the same thing.....

    Intel only distribute those as books about twice a year at most (and there's no fixed date)...but the PDF's are always available

  9. #9
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    Download the first Linux kernel (v.0.0.0.1).

    It's a very good start, so there parts, which were coded in C and parts which are coded in Assembly.

    >Yeah I didn't think it could all be done in C either, but (I think) UNIX, Linux or Windows (Not sure which one) claim to be written entirely in C.


    The most parts of Unix, Linux and Windows were written in C, modern Windows versions, like WindowsXP / WindowsME were written in C++. But parts for virtual memory and parts for processor specific funtions for all this operating systems were written in the Assembly language.

    Microsoft has developed their own Assmebler and Assembly language for their Operating Systems, called MMCASM (Microsoft Macro Assembly), which was written in ASM.

    A good start is the first Linux Kernel, google.com, reading some tutorials, the processor manufactorer websites (developer parts):
    www.amd.com
    www.intel.com

  10. #10
    stovellp
    Guest
    I've actually ordered a book on operating systems that comes with Minix, which is supposed to be really good for teaching OS's. Just waiting for it to come in. But this linux kernel 1 sounds like a good idea, I'll have to search around for it, Thanks.

  11. #11
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    Maybe it's still avaible at the kernel archives:

    www.kernel.org

    or just google it!!!

  12. #12

  13. #13
    stovellp
    Guest
    I downloaded kernel 1.0.0 (I think, something like that, lowest number there) but its all kernel and i can't find any of the actual code. Also, theres lots of calls the the Standard Libraries and stuff. I'm not so interested in the code, but more on how they got the code written on one PC into another PC that has no operating system, thats what really befuddles me.

    How could you write C/C++ code for an operating system that doesn't exist? Wouldn't you have to write your compiler for that OS first and then the C/C++ code?

  14. #14
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    I've been looking through the Linux kernel for awhile now. All ASM and straight C.

    http://www.kernel.org/pub/linux/kernel/v2.4/

  15. #15
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    Search in google for some Master Boot Record code, which can be written on floppies / for floppies. So you can write your own os loader onto the floppy.

    There you can define the whole stuff....

    The first Linux kernel does it too...

    So, if you compile it, you write it into the mbr of the floppy, then you load the files onto the floppy.

    You can boot this floppy and its os is linux with kernel 0.0.0.1

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 03:56 AM
  2. A question about windows programming
    By Hussain Hani in forum Windows Programming
    Replies: 16
    Last Post: 05-23-2007, 07:38 AM
  3. accessing Delphi written file
    By Sha in forum C Programming
    Replies: 3
    Last Post: 12-13-2006, 12:50 AM
  4. Reading IDL CORBA objects written from java
    By dpro in forum C++ Programming
    Replies: 10
    Last Post: 01-25-2006, 03:27 PM
  5. written command line password generator
    By lepricaun in forum C Programming
    Replies: 15
    Last Post: 08-17-2004, 08:42 PM