nedoPC.org

Community of electronics hobbyists established in 2002

...
Atom Feed | View unanswered posts | View active topics It is currently 19 Jan 2018 05:49



Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
[Ternary] Ternary C-like programming language 
Author Message
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Maybe 1000, but I'm relying heavily on metaprogramming (C++ templates) and generated code from flex/bison, so the total code is maybe 5-6000 lines...


19 Mar 2008 08:20
Profile
Retired

Joined: 03 Aug 2003 23:37
Posts: 1483
Location: Moscow
Reply with quote
Any news about the language and its release date ? We're waiting for it :-D


03 Apr 2008 14:44
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
I've had to rework it extensively because of a stupid design mistake I did at the beginning, that combined with a lot of other stuff taking up my time, I probably would set a pessimistic time plan with a working version beginning of the summer or something like that.

Making a programming language that is merely working good enough is one thing. I want one that is working from the core, without weird work-arounds in the code to get it to sort-of behave like C.

I'm also considering making it more different from C than originally planned. It will still use the same programming paradigm (imperative programming), but with bigger distinction between logic and mathematics, as well as some other changes.

It'll probably altogether be more intuitive from a mathematical and logical point of view. But it's still on the drawing table. I'll update later.


04 Apr 2008 04:18
Profile
Retired

Joined: 03 Aug 2003 23:37
Posts: 1483
Location: Moscow
Reply with quote
I see. Keep us informed :-)


04 Apr 2008 14:34
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Progress have been going really slow lately. I'm still very occupied with other stuff :-(


18 Apr 2008 13:29
Profile
Retired

Joined: 03 Aug 2003 23:37
Posts: 1483
Location: Moscow
Reply with quote
Same here - no time to complete other programs for Tunguska :-?


19 Apr 2008 00:42
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
I've finally had some time to work on this thing again. I've scrapped maybe half of the old code base, since it had major issues that were very hard to weed out. I managed to salvage the code for most operations, but introduced new functionality for proper support for pointers and plain-old-data types. I still have to write function code and some other stuff, but most stuff is working pretty nicely at this point.

I'll try to slap that together, and then there is going to be some major debugging. I haven't really been able to check whether the 1000-or-so lines of possible assembly code does what it's supposed to yet (since it currently only produces small pieces of code), so ... yeah. Debugging.

I'd also like to point out that it does not produce effective code. (Likely due to change in the future when more outstanding issues are cleared out)

Compare machine generated code:
Code:
; char c;
; c=c*2;
                PSH     c
                PSH     #2
                PLL     A
                PLL     tmp
                MLL     tmp
                PSH     A
                PLL     A
                STA     c


With hand written code doing the same
Code:
                LDA     c
                MLL     #2


08 Jun 2008 12:37
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
It's slowly beginning to take shape. There are still a bunch of issues to resolve before I'll make an initial release, but things are actually beginning to look a bit like C.

Here's what I've implemented so far:
Basic arithmetic, nested arithmetics, function calls, function definitions, code surrounding conditionals (I've still got to actually implement while and for, but if works), typing and a not-quite-C-compatible pointer arithmetic.

The stuff I've got to do is:
Clean the code up and add sensible error messages.
Implement conditionals.
Implement strings.
Implement incrementers/decrementers.
Feature cleanups. Right now grammar is very rigid, you have to pre-declare each function before you define them and stuff like that, but I'll remove that in the future.

The stuff I probably won't do until a later release:
Structs
Arrays
Goto:s
Optimization (the produced code is very unoptimized right now)


22 Jun 2008 12:59
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Okay, so right now it's gotten so far that I'm able to debug the instructions it's outputting by writing programs and running them in Tunguska. This is a lot of work, making sure that every possible aspect of the language works as it should, but I suspect the best way of doing it is simply to write programs, see if they behave as they should, and if not fix the problem.

On the list of stuff I've yet to do I posted earlier, these have been at least partially completed:

*Clean the code up and add sensible error messages.
*Implement conditionals.
*Implement strings.


20 Jul 2008 18:24
Profile
Admin
User avatar

Joined: 09 Jan 2003 00:22
Posts: 16040
Location: Colorado
Reply with quote
Great news! Is it available somewhere?


20 Jul 2008 19:44
Profile WWW
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Not yet. It's still so buggy I'm not comfortable with releasing even alpha or CVS versions of it. It is at least a couple of weeks away.

I will put it in the tunguska CVS when it is though, and make a note of it in this thread.


20 Jul 2008 20:21
Profile
Retired

Joined: 03 Aug 2003 23:37
Posts: 1483
Location: Moscow
Reply with quote
Great news indeed! I'm waiting for release to start use it :)


21 Jul 2008 00:21
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Yeah, it's really wonderful that it's finally taking shape. I compiled this program successfully earlier (it prints "Hello world" diagonally across the screen):

Code:
#define LOOP asm(".loop:", "JMP .loop")
#define DEBUGVAL(X) asm("LAD (" #X ")", "DEBUG")

void putcxy(char c, char x, char y);

void main() {
   char* string = "Hello world";
   char c = 0;
   while(*string) {
     putcxy(*string, c, c);
     string = string + 1;
     c = c + 1;
   }

   LOOP;

}
void putcxy(char c, char x, char y) {
   char* redraw = -265718;
   char* memory = -264262;
   memory = memory + 54 * y + x;
   *memory = c;
   *redraw = 1;
}


I'm using GCC's macro preprocessor for function macros.

Unfortunately, it also illustrates the problem at this stage: Inefficiency. It generated a whopping 226 lines or roughly a half memory page of assembly code to complete this simple task.


21 Jul 2008 07:42
Profile
Retired

Joined: 03 Aug 2003 23:37
Posts: 1483
Location: Moscow
Reply with quote
Well, seems like it generate much better code than I can do :)


21 Jul 2008 12:41
Profile
Maniac

Joined: 17 Sep 2012 14:36
Posts: 277
Location: 81.170.128.52
Reply with quote
I don't know about better, but it's systematic. The problem with assembly is that the main workload isn't writing the program, but trivial things like making sure to add the carry to the most significant tryte. Which is a horrible waste of time.

I've gotten a lot of work done today. These things are off the todo list:
* Variable scopes
* Post/pre incrementers/decrementers
* For loops
* Escape characters in strings

Never have I been as happy to see an isometric cube rendered on a screen as when this:

Code:
#define RED 0n4DD
#define GREEN 0nD4D
#define BLUE 0nDD4

void rastermode();
void putpixel(char x, char y, char c);
void repaint();

void main() {
   char x = 10;
   char y = 10;

   rastermode();

   for(x = 10; x < 110; x++)  {
     putpixel(x, 10, RED);
     putpixel(x, 110, RED);
     putpixel(x+50, 60, RED);
     putpixel(x+50, 160, RED);
   }

   for(y = 10; y < 110; y++) {
     putpixel(10, y, GREEN);
     putpixel(110, y, GREEN);
     putpixel(60, y+50, GREEN);
     putpixel(160, y+50, GREEN);
   }

   y = 10;
   for(x = 10; x < 60; x++) {
     putpixel(x, y+100, BLUE);
     putpixel(x+100, y, BLUE);
     putpixel(x+100, y+100, BLUE);
     putpixel(x, y, BLUE);
     
     y++;
   }

   repaint();
   for(;;);
}

void rastermode() {
   *(char*)(0nDDDDDB) = *(char*)(0nDDDDDB) & 0t0000N0;
}
void repaint() {
    *(char*)(0nDDDDDB) = 0t0000NP;
}
void putpixel(char x, char y, char c) {
   *(char*)(0nDDBDDD + x + 324*y) = c;
}


Compiled into this:

Image


23 Jul 2008 09:40
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

Who is online

Users browsing this forum: No registered users and 2 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® Forum Software © phpBB Group
Designed by ST Software.