Thread: OS-independet stuff?

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    70
    I have realized that such an animal does indeed exist, every compiler that won't delete pre-link created obj-files is one. If one has used no OS-calls these obj files could be booted as an operating system. But one has to place either the .obj's code itself (if it's really tiny) or (more likely) code that will load it, in the boot sector.

    If it should load not at boot - but from within Windows - I guess one must arrange for the assembler equivalent of "ORG 100h" to make room for the (theoretical) command line at the benning of it's memory space, making it an MS-DOS .com... Perhaps other X86 systems (OS/2, Linux) will run this kind aswell?

    Note that I'm not thinking that the same .com that acts as an OS at one time would also double as an application. An operating system's code beeing run as an application would of course violate the rules of the OS it's beeing run by (unless the code has little power and is of little use as an OS).

  2. #17
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    Quote Originally Posted by bithub
    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.
    Code:
    union REGS regs;
    
    regs.x.al = 0x10;
    int86 (&regs, &regs);
    Or something like that. It's been ages.

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > every compiler that won't delete pre-link created obj-files is one.
    All the object file formats I know about contain a lot of relocation information as well. They're not simply "memory dumps" of the assembler code they represent, so there's no way you can simply load them into memory, jump to where you loaded them and expect anything useful to happen.

    > Perhaps other X86 systems (OS/2, Linux) will run this kind aswell?
    I said it before, so let me say it again.
    Every OS out there has it's own "executable" format, so there's no way you can make a one size fits all format.

    But then again, I've lost interest in your ramblings.
    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.

  4. #19
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Relocatable code needs to be "located" to be useable. This is quite possible. An earlier employer of mine used Borland Turbo Pascal and assembler to build it's embedded software. The resulting relocatable object was then processed by our own locator to resolve addresses. It was then blown into a PROM at a fixed offset above a simple BIOS written in raw hex in a seperate PROM. The application was an executive loop and a series of state machines. Was over ½million lines of code.

    Reading your posts, I would suggest that this is beyond your current knowledge/expertise level.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

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, 02: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-28-2002, 12:16 AM