OS-independet stuff?

This is a discussion on OS-independet stuff? within the C++ Programming forums, part of the General Programming Boards category; Does anyone know of a C++ compiler (free if possible) that can create OS-independent .COM executables for X86 (without a ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    70

    OS-independet stuff?

    Does anyone know of a C++ compiler (free if possible) that can create OS-independent .COM executables for X86 (without a lot of, say, "hello I'm a windows-program"-type of code) This is because one day I want to create my own OS and/or compiler. I'd also like a modern 32-bit equivalent of the old Debug that came with dos/windows that displayed 16-bit machine code as ASM, so that I can see what the compiler creates...

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    > create OS-independent .COM executables for X86
    No such animal exists.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    >> I'd also like a modern 32-bit equivalent of the old Debug that came with dos/windows

    Until now I had never realized that debug.exe is 16-bit, lol!


    edit: Is there a 32-bit version of debug.exe?
    Last edited by BMJ; 01-11-2005 at 12:51 PM.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    70

    Exclamation

    No such animal exists
    I'm sure does! They made windows using some generic C/C++, right folks?
    Last edited by willkoh; 01-11-2005 at 02:24 PM.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    > create OS-independent .COM
    > I'm sure does! They made windows using some generic C/C++, right folks?

    Right. That is because COM is a Microsoft executable format.

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    WARNING - I don’t have any hands-on experience with this stuff… So the following is hearsay, assumption, and speculation:

    I think the Linux GCC compiler can do what you want. Because with Linux, you can boot a bootloader and then compile the OS… before you have a (complete) OS installed.

    This is because one day I want to create my own OS and/or compiler.
    When you’re ready to learn to write an operating system, check-out Minix. Minix was created as a learning tool. The Minix source is free (not open source), but you have to pay for the book.

    Of course, you can study the Linux source code. But, I wouldn’t attempt that unless you can find a really good study guide. (Linux 2.4 is 2.4 Million lines of code!!!)


    ...that displayed 16-bit machine code as ASM,
    You need a disassembler. A good Compiler/IDE with a debugger should include a disassembler. I’m pretty sure that the MS Visual C++ debugger has one.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    > I'm sure does! They made windows using some generic C/C++, right folks?
    Sure, and what about Linux, Solaris, NetBSD, OpenBSD, FreeBSD and a host of other operating systems which you've never heard of.
    None of those are going to think much about 16-bit COM files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I'd also like a modern 32-bit equivalent of the old Debug that came with dos/windows that displayed 16-bit machine code as ASM
    For a command line tool, try ntsd. WinDbg is the GUI version.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    70
    Well to those who say .COM's are either always 16-bit (not true) or a microsoft concept (not true either) I just want to let them know. I've read about them in old assembler books. The exe:s are relocatable so they can be put and operate in any area memory were space is available, that's the main/defining difference... A .COM is simple usually not very OS oriented (because it's either the startup-file of an OS or an old and therefore simple tool for that OS) and would be the thing to use for learning machine code or startup of an OS (when you know free memory starts at 0)

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    Still, you're going to be SOL as soon as your program wants to say
    - display anything
    - read input
    - read a file.
    Because all those services are very specific to each and every OS.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User
    Join Date
    Jan 2005
    Posts
    70
    Well, there are the BIOS routines for doing such things (it has text-printing and I think a standard screen mode for that). It has not file reading (since it's specific to the OS and FileSystem), but sector reading. Then I can learn how to communicate with the graphics card for doing manual (more advanced) graphics...

    There has to be some generic C/C++ compiler!

  12. #12
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Sure because every BIOS is the same too

    -err no.

    Try learning something before speaking next time. If you really want to get into OS design then learn assembly. This will serve as the base for your OS and it is the only way to start to build one.

    If you want to get into compiler design check out the red dragon book, do a search on this board for other books, or *gasp* try google.

    You are correct as in the idea of executable programs is not microsoft original, however the implementation of an executable IS OS dependant and thus there is no "generic" compiler that you speak of since the implementation is different for each OS.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  13. #13
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Well, there are the BIOS routines for doing such things (it has text-printing and I think a standard screen mode for that). It has not file reading (since it's specific to the OS and FileSystem), but sector reading. Then I can learn how to communicate with the graphics card for doing manual (more advanced) graphics...
    This is all correct, but it requires assembly. The bios interrupt is 0x10, and you use the registers AH, AL, BH, and BL in order to set the text and attributes. No C or C++ compiler (that I know of anyways) is going to help you here.

  14. #14
    Registered User
    Join Date
    Jan 2005
    Posts
    70
    ...but they did use C rather than assembler to make windows!

  15. #15
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    To make MOST of of windows. Bootstrap loaders have to be written in assembly. And the code used to make windows isn't compiled on any magic compiler. It's just that you won't be able to call any functions that are normally defined by the OS. In other words, you'll have basic C syntax, but you'll have to code all your routines for input, etc... in assembly.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiles on OS X but not in Linux
    By cunnus88 in forum C++ Programming
    Replies: 9
    Last Post: 03-28-2007, 03:22 PM
  2. Detecting if OS is Windows???
    By Ktulu in forum Windows Programming
    Replies: 2
    Last Post: 11-19-2006, 01:49 AM
  3. Programming an OS
    By minesweeper in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-09-2002, 06:51 PM
  4. Your stuff
    By smog890 in forum C Programming
    Replies: 6
    Last Post: 06-13-2002, 11:50 PM
  5. How do they compile code for an OS ?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 03-27-2002, 11:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21