Page 1 of 4

New programming lang.

Posted: Thu Jan 24, 2008 6:57 pm
by bloodhound23
Yes, I know many of you think the idea of creating a new programming language specifically for OSDEV, but that is what I have set out to do. I feel that even though C was designed for system programming, that the current C compilers have neglected that purpose. Even though an OS can be written in C I will create a programming language for OSDEV that works the way my mind works.

Any thoughts on this?

Posted: Thu Jan 24, 2008 7:04 pm
by Pyrofan1
all i can say is good luck. have fun turning your language into machine code.

Re: New programming lang.

Posted: Thu Jan 24, 2008 7:07 pm
by SpooK
bloodhound23 wrote:Yes, I know many of you think the idea of creating a new programming language specifically for OSDEV, but that is what I have set out to do. I feel that even though C was designed for system programming, that the current C compilers have neglected that purpose. Even though an OS can be written in C I will create a programming language for OSDEV that works the way my mind works.

Any thoughts on this?
Yeah... think about this long and hard. You will spend much more time trying to come up with a compiler instead of just adapting to the nuisances of current tools.

Also, I guarantee you that along the way, you will start to learn and understand why certain compilers offer and do certain things. You may come up some unique or more efficient code, but for the most part you'll be spending your time reinventing a wheel so that *you* understand it better... but not perhaps all others.

Posted: Thu Jan 24, 2008 7:18 pm
by mathematician
You could try a language called Oberon, which, like C, was developed specifically so that an OS could be written. It was invented by the same guy who came up with Modula and Pascal. I suspect that the compiler can be downloded for free.

Posted: Thu Jan 24, 2008 7:43 pm
by Jef
Don't forget that the creation of a compiler has almost the same difficult level of creating an OS.

I don't know your background, maybe you are a very clever man, with huge knowledge of programming etc.

My opinion is that you try to make something big and difficult.
I have create PE-32 patcher, interpreter for asm x86, dynamic asm code generation for encryption/decryption routines, and more...
After a lot of low level projects, i decide to make a compiler (something between asm & C ).
I soon realize that is more attractive (for me) to make an OS.

BUT, if you really want to do it,
good luck from me,
and if you need any help about PE-32 executables, i am here to help you.

(its a good start to understand what other compilers do and why they do)

Posted: Thu Jan 24, 2008 8:14 pm
by blackoil
Hi, I made a C-like compiler in assembly for osdev, with little difference from C syntax. such as, int[5] array, int*[5] arrayptr, int[5][5]* pArray. If you know how to operate the treenode, it's not difficult to start.

Posted: Fri Jan 25, 2008 2:31 am
by Solar
I have thought about this once myself.

There are three questions you must answer for yourself before setting out to create a new language for your OS to be developed in:

1) Do you do this for the sake of the result (creating an OS), or for the sake of the process (hacking fun)?

If the answer is "the process", well, go ahead and do it. You don't have to answer the other two questions. However, if you change your mind about answer 1) later on, don't be surprised if you suddenly have to face question 2) and 3), and you probably will not like the answers.

2) Will there ever be someone else helping you in your OS endeavour?

If the answer here is "no", you could as well stop now. Without help, you will never get beyond the basic stages. Getting an OS anywhere requires dozens of man-years of development on the hardware generation you started with. Reconsider your answer to 1), above.

If the answer here is "yes", then:

3) Do the benefits of your new language, whatever they are, outweight the disadvantages?

A new language means there will be only one toolchain in the beginning. Untested. Changing. Not as well documented. With few or no clues to be google'd when problems arise. Perhaps not even available cross-platform.

Problems might arise that after hours and days of cruel debugging end up as being flaws in the language, or its compiler, with a much higher chance than with C, C++, ASM or their ilk. You'd have to tell your editor how to do the highlighting and indenting, instead of using what's readily available. There won't be any source / style checkers unless you write them yourself. Many small, seemingly insignificant details, but they do sum up.

For me, personally, a non-mainstream language is an outright show-stopper. While I like helping someone with his C/C++/Perl/SQL/... problem when I come across it, I don't have the time or inclination to learn a niche, single-purpose language just so I can spend my spare time on someone else's project - I'd rather learn a new language that might benefit my resume as well as my hobby. I know many other professional developers to think likewise.



As such, I decided against it back when I pondered the question. Your mileage might vary, but you do have to consider those three questioons.

Posted: Fri Jan 25, 2008 5:52 am
by bloodhound23
Considering all of this, I have decided to go with this plan:
  • Plan everything out
    write the bootloader(in hex)
    write kernel etc.(in fasm assembler)
    build from there.
    maybe then I will write a compiler for my OS
    estimated time to complete: 6+ years(more or less)

Posted: Fri Jan 25, 2008 6:34 am
by Solar
bloodhound23 wrote:write the bootloader(in hex)
*cough* :?:

Posted: Fri Jan 25, 2008 7:49 am
by mathematician
bloodhound23 wrote: write the bootloader(in hex)
Why exactly would you want to do that? If you got even a single bit in the wrong place your program would fail, and, with 512 bytes worth of hexadecimal numbers in front of your eyes, that errant bit (if there was only one) wouldn't exactly be easy to spot.

Debugging in a human readable language can be bad enough.

Posted: Fri Jan 25, 2008 1:46 pm
by bloodhound23
surprisingly I can debug hex pretty comfortably. Hardcoding Rocks!!

Posted: Fri Jan 25, 2008 2:19 pm
by Brynet-Inc
bloodhound23 wrote:surprisingly I can debug hex pretty comfortably. Hardcoding Rocks!!
Who are you trying to impress? :roll:

Maintaining that would be a nightmare, use the published mnemonics.. :wink:

Posted: Fri Jan 25, 2008 4:45 pm
by bloodhound23
Brynet-Inc wrote:
bloodhound23 wrote:surprisingly I can debug hex pretty comfortably. Hardcoding Rocks!!
Who are you trying to impress? :roll:

Maintaining that would be a nightmare, use the published mnemonics.. :wink:
512 bytes is a small amount, that's why I can debug it.

Posted: Fri Jan 25, 2008 5:30 pm
by mathematician
bloodhound23 wrote:
512 bytes is a small amount, that's why I can debug it.

Code: Select all

db  0EBh, 010h, 010h, 000h, 00Ah, 000h, 000h, 07Eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
db  000h, 000h, 0FAh, 0FCh, 01Eh, 033h, 0C0h, 08Eh, 0D8h, 08Eh, 0D0h, 007h, 0BCh, 000h, 07Ch, 0FBh
db  088h, 016h, 0F2h, 07Dh, 0C7h, 006h, 0FBh, 07Dh, 0F0h, 001h, 080h, 0FAh, 081h, 076h, 006h, 0C7h
db  006h, 0FBh, 07Dh, 070h, 001h, 089h, 036h, 0F4h, 07Dh, 0E8h, 0EDh, 000h, 066h, 03Dh, 000h, 000h
db  0FEh, 000h, 076h, 027h, 0C6h, 006h, 0FDh, 07Dh, 042h, 066h, 026h, 08Bh, 044h, 008h, 066h, 040h
db  066h, 003h, 006h, 0F6h, 07Dh, 066h, 0A3h, 00Ah, 07Ch, 0A0h, 0FAh, 07Dh, 0A2h, 004h, 07Ch, 08Dh
db  036h, 002h, 07Ch, 0B4h, 042h, 0CDh, 013h, 072h, 04Fh, 0EBh, 027h, 0C6h, 006h, 0FDh, 07Dh, 002h
db  026h, 08Ah, 074h, 001h, 026h, 08Ah, 04Ch, 002h, 026h, 08Ah, 06Ch, 003h, 033h, 0C0h, 08Eh, 0C0h
db  0FEh, 0C1h, 002h, 00Eh, 0F6h, 07Dh, 0BBh, 000h, 07Eh, 0A0h, 0FAh, 07Dh, 0B4h, 002h, 0CDh, 013h
db  072h, 026h, 08Dh, 036h, 0F2h, 07Dh, 0BBh, 000h, 07Eh, 08Bh, 047h, 003h, 081h, 07Fh, 003h, 029h
db  0FAh, 075h, 00Fh, 08Bh, 047h, 005h, 081h, 07Fh, 005h, 056h, 08Dh, 075h, 005h, 0EAh, 000h, 07Eh
db  000h, 000h, 08Dh, 036h, 09Ah, 07Dh, 0EBh, 004h, 08Dh, 036h, 0BEh, 07Dh, 0E8h, 00Ah, 000h, 08Dh
db  036h, 0DCh, 07Dh, 0E8h, 003h, 000h, 0FBh, 0EBh, 0FEh, 0ACh, 00Ah, 0C0h, 074h, 008h, 032h, 0FFh
db  0B4h, 00Eh, 0CDh, 010h, 0EBh, 0F3h, 0C3h, 056h, 09Ch, 066h, 050h, 066h, 0C1h, 0E8h, 010h, 0E8h
db  020h, 000h, 066h, 058h, 0E8h, 01Bh, 000h, 08Dh, 036h, 0EFh, 07Dh, 0E8h, 0DBh, 0FFh, 09Dh, 05Eh
db  0C3h, 056h, 053h, 09Ch, 0E8h, 00Bh, 000h, 08Dh, 036h, 0EFh, 07Dh, 0E8h, 0CBh, 0FFh, 09Dh, 05Bh
db  05Eh, 0C3h, 060h, 086h, 0C4h, 0C0h, 0C0h, 004h, 0C0h, 0C4h, 004h, 08Bh, 0D0h, 0B9h, 004h, 000h
db  08Ah, 0C2h, 0C1h, 0EAh, 004h, 024h, 00Fh, 004h, 030h, 03Ch, 039h, 076h, 002h, 004h, 007h, 032h
db  0FFh, 0B4h, 00Eh, 0CDh, 010h, 0E2h, 0E9h, 061h, 0C3h, 052h, 0B4h, 008h, 0CDh, 013h, 08Ah, 0C1h
db  083h, 0E0h, 03Fh, 040h, 0FEh, 0C6h, 0F6h, 0E6h, 0C1h, 0E9h, 006h, 041h, 0F7h, 0E1h, 066h, 025h
db  0FFh, 0FFh, 000h, 000h, 066h, 0C1h, 0E2h, 010h, 066h, 00Bh, 0C2h, 05Ah, 0C3h, 000h, 000h, 000h
db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 04Fh, 070h, 065h, 072h, 061h, 074h
db  069h, 06Eh, 067h, 020h, 073h, 079h, 073h, 074h, 065h, 06Dh, 020h, 06Ch, 06Fh, 061h, 064h, 065h
db  072h, 020h, 06Eh, 06Fh, 074h, 020h, 066h, 06Fh, 075h, 06Eh, 064h, 02Eh, 020h, 000h, 048h, 061h
db  072h, 064h, 020h, 064h, 072h, 069h, 076h, 065h, 020h, 063h, 06Fh, 075h, 06Ch, 064h, 020h, 06Eh
db  06Fh, 074h, 020h, 062h, 065h, 020h, 072h, 065h, 061h, 064h, 020h, 000h, 053h, 079h, 073h, 074h
db  065h, 06Dh, 020h, 068h, 061h, 06Ch, 074h, 065h, 064h, 02Eh, 05Ch, 06Eh, 00Dh, 00Ah, 000h, 00Dh
db  00Ah, 000h, 00Ch, 001h, 000h, 000h, 001h, 000h, 000h, 000h, 00Ah, 000h, 000h, 000h, 055h, 0AAh
There is a bug in that (because I have just put it there). Can you spot it?

Posted: Fri Jan 25, 2008 5:58 pm
by bloodhound23
Before I give this a go, do you not realize that I can just disassemble this and look at the asm version?