OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:10 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: nanix and nanc
PostPosted: Sun Nov 02, 2014 6:31 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
nanc
After the CompilerDev topic a while ago, I started writing my own compiler. Now, after a few weeks, it's getting ready to being somewhat usable. My compiler compiles my own language, called nanlang. The compiler itself is called nanc.

I wanted my compiler to be modular. The main reason for that is maintainability, as one big block of code would become unmaintainable after some time. First off, I was only writing it for x86. After I tested it and tried some other stuff out, I decided to start over, hoping not to do the same mistakes again that I did with the first version. It has grown and become nanc by now. Currently, it is only compiling code for amd64, but ARMv6 is planned.

The reason I'm doing this is simple: I want to write my OS with this language. I want to use the same language for both OSdev and CompilerDev. I didn't choose C, as I think it's not suited for compiler development (my own opinion, haters gonna hate). C++ seems too unintuitive to me. Other ones are just crap when using them for OSdev. (Please don't start a flamewar, it's my opinion. It will not change.)

nanix
This will be the OS written using nanlang. I want it to run on x86-64 UEFI PCs and Raspberry Pis.

It isn't started yet, not even planning is completed, so I don't know about how I'll implement things, at least right now.

nanas
nanas is a assembler, featuring a new clean and human-readable syntax. It has no fixed instruction order, but instead it follows the way humans thing (e.g. "mov(e) 0 (to) eax", "cmp 4 (to) eax", leaving out everything in the braces). It does not use any commas. Intel syntax is scary, AT&T even more. Currently, it is capable of producing (horrible, but working) ELF64 binaries. Only few instructions are supported yet.

Download
Releases will be available through GitHub.

_________________
managarm


Last edited by no92 on Thu Dec 04, 2014 12:29 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Sun Nov 02, 2014 8:59 am 
Offline

Joined: Sun Jun 08, 2014 10:39 am
Posts: 15
It seems your compiler is written in PHP.
Perhaps you could implement a web interface for nanc, which prints out the asm code for a given code.

_________________
https://github.com/MartinErhardt/Lizarx


Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Sun Nov 02, 2014 11:40 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
I already took that in consideration, but I won't do it. It would be no problem to implement it, but I plan rewriting it in my own language soon, which isn't a web development language at all.

I don't think somebody would use such an interface, as it's not a problem to run such the compiler on most architectures. You also have to take in account that you don't get an assembled object file or an executable, but only assembly.

You may suggest having the compiler in both languages; but maintaining it would be a nightmare then.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Sun Nov 02, 2014 12:08 pm 
Offline
Member
Member
User avatar

Joined: Mon Mar 05, 2012 11:23 am
Posts: 616
Location: Germany
Nice work! will have a look at the code once i'm at home.
no92 wrote:
You may suggest having the compiler in both languages; but maintaining it would be a nightmare then.
How will you bootstrap your compiler then? Distribute binaries?

_________________
Ghost OS - GitHub


Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Sun Nov 02, 2014 12:28 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
My plan for the next few months is to get the current compiler (written in PHP) to an acceptable state; after that, I'll begin writing it in nanlang, but compiling it with the old compiler. After both have the same set of features, every new compiler release will be compiled with the previous release.

With the first release of the nanlang-based rewrite, the old PHP-based compiler will get deprecated.

Both source and binary packages will be released by me, but probably only for Linux and nanix (maybe OS X, not quite sure yet). This will not happen in the next few weeks, as the current compiler and the rewrite will take a lot of time.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Fri Nov 21, 2014 2:13 pm 
Offline
Member
Member
User avatar

Joined: Mon Mar 05, 2012 11:23 am
Posts: 616
Location: Germany
I'm moving this from my Ghost article to yours so we can discuss. :)
no92 wrote:
That one may take a while - and I do plan to add some runtime routines for reflection, which may make things more complicated.
You'll need that anyway if you want proper inheritance and something like Java's instanceof.

no92 wrote:
My plan for the next few months is to get the current compiler (written in PHP) to an acceptable state; after that, I'll begin writing it in nanlang, but compiling it with the old compiler. After both have the same set of features, every new compiler release will be compiled with the previous release.

With the first release of the nanlang-based rewrite, the old PHP-based compiler will get deprecated.
If you no longer provide a source release in PHP for newer versions, users are forced to use the binaries of your compiler. How could they then for example get it running on a new system where this binary does not work, and where only existing packages (preferably PHP then) work?

_________________
Ghost OS - GitHub


Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Sun Nov 30, 2014 10:49 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
@max: They will download the binary and the source and compile the new (source) compiler with the old (binary) one. The binary will only work on nanix though (I may port it to Ghost later on, but that would require deep hacks in execve/fork).

_________________
managarm


Top
 Profile  
 
 Post subject: Re: nanix and nanc
PostPosted: Thu Dec 04, 2014 12:31 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
nanas, an assembler, has been added to the project. Therefore I updated the first post.

_________________
managarm


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group