Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Two low level questions (again)

This topic is 6201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all. Thanks to your replies on another post similar to this, I have generated some ideas, and yet more questions. So thank you. My first question is this. I have written my basic compiler framework, in QBASIC, just to do some simple testing. I am pretty sure it is going to be ported to C, but I wanted to get down some things first. It supports a few commands like PRINT and INPUT. The code breaks down into 16-bit real mode code that uses all BIOS calls, no DOS at all (for OS development eventually). It outputs assembly code, oriented toward NASM. I use DEBUG to translate it into hex opcodes. Using QBASIC's binary file output abilities, I can dump the code as needed to a .COM file. When comparing the output to a NASM output (both .COM files, viewed in a text viewer, same exact assembly code) they look pretty much the same, except for some whitespace. All the characters are the same. The NASM one works, and mine usually gives me errors, as in crashing. What am I doing wrong, and what can I do to fix or correct this? When my OS boots, I want to run plain .BIN files. Are .BIN files executable? I am going to enter the filename, hit return, and expect it to execute. What do I have to do with .BIN files to get them to run, and how to they go from code to final output? Are .BIN and .COM the same thing? What are the differences? This sounds odd but I don't know how to ask it. Thanks very much guys. ===== Khaos ===== Edited by - khaos on November 21, 2001 10:30:18 PM

Share this post

Link to post
Share on other sites
If you are talking about writing your own OS, there is no such thing as an ''executable format'' until you decide on what you are going to support.

That is, .EXE files are of a specific format that defines segments within the file which are loaded into different segments of memory. It is up to the operating system to interpret that format. This is a COFF format, I think? Linux supports other formats like ELF and a.out for example.

A .COM file is raw code and has no headers and structures within it. Your .BIN file is probably the same kind of thing. When first booting an operating system you need some kind of .BIN file, unless you can fit all the initialisation code in 400 something bytes (the boot sector - partition information).

Basically, what you need to do is; in your boot code, load the bin file into a particular area in memory then jump into it. This is just machine code that then enables you to do more things.
Bear in mind that without a file system you will not be able to find the .BIN file so it might be worth reserving x number of sectors at the beginning of the partition for your startup code.
This is the way that Linux works. It has (I think) 9 sectors of code at the beginning of the disk, which is enough code to get a basic file system implemented, in order to then run the kernel.

I may not have explained this very well but I hope it helps

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!