Octocontrabass wrote:
BenLunt wrote:
There is a free and easy to use assembler found at
This assembler is very DOS-centric. For learning x86 assembly on a modern OS, it's much better to use an assembler that natively produces PE (Windows) or ELF (Linux) object files. YASM and gas both meet this requirement, and both are cross-platform, so you can use whichever you prefer. Fair warning though, gas uses AT&T syntax by default.
You are correct, this assembler is made for DOS, but only to be executed from DOS, not DOS specific output. I use NBASM to create binary files. NBASM has been written to specifically cater for my needs in OS development, as so does the C compiler that is on that same page. Alex, who frequents this forum wrote that
C compiler and I ported it to my assembler, giving it a few additions, mainly to allow far address access.
My loader file is 90% C (with the 10% being inline assembly) all compiled to assembly ready for the NBASM assembler. It is a mix of 16-bit and 32-bit assembly output all indicated with a simple #pragma line.
Again, don't get me wrong, my assembler and C compiler (ported from Alex's) is not the next greatest assembler and compiler. It is simply catered to my needs for OS development only, yet I figured that others might benefit from it, so I have released it.
As for some of the additions I have made to the compiler, and please note are absolutely *not* ANSI/C99/etc. compatible, are the addition of the FARx type specifiers. For example:
Code:
bit8u farF *a_far_ptr;
will specify to the compiler to add the "fs:" segment override to any access to "a_far_ptr".
Code:
mov ebx,[a_far_ptr]
mov al,fs:[ebx]
Then all I have to do is while using inline assembly, set up the FS segment register/selector and all access to "a_far_ptr" will be from that segment/selector region.
Alex has done a wonderful job with this compiler and I am sure he has made many improvements to it since the last time I have looked, but I have made changes to it to cater to my needs. Please keep that in mind, I wrote it to cater to my needs. period.
If anyone uses my C compiler (NBC) and/or assembler (NBASM) for their OS development and has any questions on how to use it, please send me an email or better yet, post here to this forum. I am glad to help people learn.
Thanks,
Ben
P.S. I don't mean to start a war here, or offend anyone, but in my opinion, you are defeating the purpose of OS development if you use a compiler or assembler that creates an output file already specific to another OS, for example, PE files. In my opinion, do not write your OS to load PE files. This relies on the fact that you are catering your OS to rely on the format of another OS. Create your own format. Just my humble opinion though.