Page 1 of 1

Hobby Programming Language

Posted: Tue Dec 11, 2012 7:47 pm
by rob
Hello everyone!

I got interested in OS development some time ago, primarily tinkering in assembly language. More recently, I've found myself experimenting with compiler design, a topic that may very well have eclipsed my interest in operating systems (heresy around here, I'm sure :wink: ). I thought writing a tiny, low-level language (in some respects, a high-level assembly given that it's not portable) that compiles to x86 assembly code would be a fun project, and I'd like to share the product of my work thus far with you. If anyone has any questions, suggestions, or finds a use for it in a separate project, I'd love to hear about it!

Some features of the language (dubbed "U"):
* Simple syntax - This is largely due to it being a hobby project, but this could make it a good candidate for teaching the basics of how compilers and assembly code work. It also lacks some of C's idiosyncrasies (header files, etc).
* Compiles to 16-bit Intel x86 assembly code - The output can be read by a human (again, potentially good for learners) and doesn't require knowledge of a linker (executables are, of course, created with an assembler like NASM or FASM).
* Inline assembly - the language makes incorporating assembly code into the main program flow quite simple (since I'm not shooting for portability)

You can download the source and documentation, here:
https://github.com/upcrob/u-programming-language

Again, questions/comments are welcome (just post below). I can't promise I'll have time to implement features if they get requested, but I'm open to hearing about them. Keep in mind, I'm not trying to create any sort of "C killer" - if you're writing production code or an OS that needs to exit real mode, this language isn't for you. Nonetheless, I'd love to see it used in a small OS project like MikeOS, but we'll see what happens.

Have fun!

Re: Hobby Programming Language

Posted: Wed Dec 12, 2012 7:45 am
by bubach
Interesting project, and I wish you good luck! Looking forward to seeing a self-compiling version. ;)

Re: Hobby Programming Language

Posted: Thu Dec 13, 2012 5:14 pm
by rob
Thanks, though I can't say that I'm quite that ambitious. :D

Re: Hobby Programming Language

Posted: Mon Dec 17, 2012 9:00 am
by mansi21
That sounds interesting =D>
How did you come up with this idea? :idea: Very impressive..looking forward for the final one!

Re: Hobby Programming Language

Posted: Mon Dec 17, 2012 5:42 pm
by rob
I developed it largely because assembly was too low-level and C was too portable for me - I wanted to know exactly how my high-level code was being translated down to the machine level.

And just to be clear, the current version is functional. I just say that it's a work in progress because in my experience, a project hasn't reached its 'final' or 'complete' version until its dead. :wink: Feel free to download the source and give it a try!

Re: Hobby Programming Language

Posted: Tue Dec 18, 2012 3:52 am
by Love4Boobies
Have you looked into HLA? It is a high-level assembler, with support for structured, procedural, and OO programming. It might even have support for generic programming---I am not certain.

Re: Hobby Programming Language

Posted: Wed Dec 19, 2012 6:31 pm
by rob
I looked into HLA once upon a time. By the time I got around to working on the U compiler, I was more interested in the project itself than its potential uses (sounds kind of like any given IBM product when I put it that way in writing). Otherwise I probably would have looked into something like HLA or C--. This hobby aspect has been really been the primary motivator behind it. Any outside use it gets is just a bonus.

Re: Hobby Programming Language

Posted: Mon Jan 14, 2013 2:02 am
by joviermark
rob wrote:Hello everyone!

I got interested in OS development some time ago, primarily tinkering in assembly language. More recently, I've found myself experimenting with compiler design, a topic that may very well have eclipsed my interest in operating systems (heresy around here, I'm sure :wink: ). I thought writing a tiny, low-level language (in some respects, a high-level assembly given that it's not portable) that compiles to x86 assembly code would be a fun project, and I'd like to share the product of my work thus far with you. If anyone has any questions, suggestions, or finds a use for it in a separate project, I'd love to hear about it!

Some features of the language (dubbed "U"):
* Simple syntax - This is largely due to it being a hobby project, but this could make it a good candidate for teaching the basics of how compilers and assembly code work. It also lacks some of C's idiosyncrasies (header files, etc).
* Compiles to 16-bit Intel x86 assembly code - The output can be read by a human (again, potentially good for learners) and doesn't require knowledge of a linker (executables are, of course, created with an assembler like NASM or FASM).
* Inline assembly - the language makes incorporating assembly code into the main program flow quite simple (since I'm not shooting for portability)

You can download the source and documentation, here:
https://github.com/upcrob/u-programming-language

Again, questions/comments are welcome (just post below). I can't promise I'll have time to implement features if they get requested, but I'm open to hearing about them. Keep in mind, I'm not trying to create any sort of "C killer" - if you're writing production code or an OS that needs to exit real mode, this language isn't for you. Nonetheless, I'd love to see it used in a small OS project like MikeOS, but we'll see what happens.

Have fun!
Wish you all the best , consider c++ too.

jovier.

Re: Hobby Programming Language

Posted: Mon Jan 14, 2013 5:37 am
by qw
Nice piece of work indeed. How exactly is dynamically allocated memory handled? If I declare a pointer byte[] p = 10:5, then does p = "Hello, world!" store "Hello world" into address 10:5 or does it assign a new address to p?

Re: Hobby Programming Language

Posted: Sat Jan 19, 2013 6:30 pm
by rob
Hobbes wrote:Nice piece of work indeed. How exactly is dynamically allocated memory handled? If I declare a pointer byte[] p = 10:5, then does p = "Hello, world!" store "Hello world" into address 10:5 or does it assign a new address to p?
If you assigned, "Hello, world!" to p, p would then be pointed to the location of "Hello, world!" in memory (not 10:5 anymore).

The core language doesn't support dynamic language allocation, so you would have to write your own malloc(). Assuming you had this (and some string functions, in this case strcpy()), you could do something like this:

Code: Select all

byte[] p = malloc(20);        // allocate memory and point p to it
strcpy(p, "Hello, world!");   // copy "Hello, world!" to the location pointed to by p
Alternatively, if you knew you were going to put the string at a position like 10:5, you could do something like this:

Code: Select all

strcpy(10:5, "Hello, world!");

Re: Hobby Programming Language

Posted: Tue Dec 05, 2023 12:53 am
by lauryfriese
Looking forward for the final one!