Tunguska the ternary emulator

Balanced Ternary Numeral System - forum was moved from http://ternary.info

Moderator: haqreu

eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I just uploaded the GTK code to the CVS. I didn't want to risk a hard drive breakdown or something undoing all my work. It's not remotely workable at the moment though.

Oh, and Tunguska is a year old now. It's 15,558 lines of code now. I think that is pretty decent for a hobby project.
Mac Buster
Retired
Posts: 1474
Joined: 03 Aug 2003 22:37
Location: Moscow

Re: Tunguska the ternary emulator

Post by Mac Buster »

Yes, very good progress for one year :) Thank you!
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I haven't had a lot of time to work on Tunguska lately, but I have added a new feature to the CVS today (which is really to make both the transfer to faster integer based internal logic, and the GTK interface easier to implement): Change hooks to memory cells.

Previously, every device (the screen and so on) had to scan their memory range after every instruction to see if the data has changed, but now the trytes themselves will tell their respective peripherals that they have changed.
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I should have done this a long time ago, but I just added much needed malloc() and free() functions to the 3cc memory image. So you can now take advantage of dynamic memory allocation! You can make linked lists, and trees, and all sorts of things!

They are pretty crude, and can only allocate a maximum of 1000 chunks at 27 words each at the moment, but... it works!

I may change the chunk size and count later (probably up to 10,000 or something, since that's approximately 40% of the addressable memory, which seems a fair number)
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I've been working a little on the 3CC memory image for Tunguska. I've added basic disk I/O now, and I'm working on a very simple file system loosely based on the one used in RT-11 (neither are in the CVS yet).

Other features I'm planning are:
A DEBUG command like the one in DOS (that can display memory and process assembly directly in the memory)
File management commands (when the file system is done, obviously)
A simple BASIC interpreter to replace the command prompt
Mac Buster
Retired
Posts: 1474
Joined: 03 Aug 2003 22:37
Location: Moscow

Re: Tunguska the ternary emulator

Post by Mac Buster »

Once again - very good news! :) Could you please explain me how can I connect to CVS from Ubuntu? I've got it installed into VirtualBox in Windows now.
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I don't know how detailed help you need.

Create a folder somewhere you want to build Tunguska, and create a text file called Makefile, and copy the following lines into it:

Code: Select all

TARGETS=tunguska_sources tunguska_3cc tunguska_memory_image_sources memory_image_3cc
all: co 
co:
        cvs -d:pserver:anonymous@tunguska.cvs.sourceforge.net:/cvsroot/tunguska login
        cvs -z3 -d:pserver:anonymous@tunguska.cvs.sourceforge.net:/cvsroot/tunguska co -P $(TARGETS)

build:
        make -C tunguska_3cc clean all
        make -C tunguska_sources clean all
        make -C memory_image_3cc clean all
Then you open a console (or terminal or whatever they're called), go to this directory, and run "make co build"

And it will check out and build the source tree. It may ask you for a password at some point, but it's safe to just press enter.


----

Heh, I just downloaded the CVS onto my old laptop. It runs a pretty old version of slackware, so I had to really coerce it into compiling at all, and it's so slow I only get about 100 thousand operations per second (I can get almost 3,000 on my workstation)
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I've completed the experiment with all host integer logic in Tunguska, and it turned out to be a failure.

The current mode of operation is faster. It may still be possible to use some of the algorithms to fix the bottlenecks in the current implementation though.
Mac Buster
Retired
Posts: 1474
Joined: 03 Aug 2003 22:37
Location: Moscow

Re: Tunguska the ternary emulator

Post by Mac Buster »

Well, negative experience is very important too :) Now you know what way does not make code faster.
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

It's still a theoretically interesting concept, since it is much denser than array coded ternary arithmetic.

To code a n wide word in regular binary, you require 2*n bits. But the host integer method only requires n*log(3)/log(2) bits (rounded up).

So, to represent 20 ternary digits with the regular algorithms, you need 40 bits, but with the host integer method you only need 32.
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

I'm seriously considering a major overhaul of the core code of Tunguska. It would be largely backwards-compatible with current Tunguska assembly code (and thus also 3CC code), but use 9 digits per word instead of 6, and add more instructions and address modes.

There are fundamental problems with Tunguska as it is right now. Most of them stem from how it was written completely ad-hoc, with no real aim or sense of direction. It is therefore poorly modularized, impossible to fork, really difficult to modify, etc. It superficially looks somewhat neat, but it really is quite a mess.
User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Tunguska the ternary emulator

Post by Shaos »

Do you plan to keep OLD Tunguska in "frozen" state like Tunguska-1 and develop NEW Tunguska as Tunguska-2? I still want to do something interesting with "old good" Tunguska ;)
eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Re: Tunguska the ternary emulator

Post by eudoxie »

Yeah, that's how I had it planned.

Classic Tunguska a working and pretty stable system, so it doesn't make sense to throw all that work away to start over with new bugs and instabilities.
User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Tunguska the ternary emulator

Post by Shaos »

I got last sources, but it failed to compile - it looks like it requires "gtksourceview-2.0", that my Slackware-12.2 doesn't have...
User avatar
Shaos
Admin
Posts: 23989
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Tunguska the ternary emulator

Post by Shaos »

Shaos wrote: I got last sources, but it failed to compile - it looks like it requires "gtksourceview-2.0", that my Slackware-12.2 doesn't have...
I took it from here in source code
http://ftp.acc.umu.se/pub/gnome/sources ... eview/2.0/