nedoPC.org

Electronics hobbyists community established in 2002
Atom Feed | View unanswered posts | View active topics It is currently 27 Apr 2024 14:47



Reply to topic  [ 273 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 19  Next
Tunguska the ternary emulator 
Author Message
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
The problem was actually very silly. I used to have these constructions like

memref("DAD", "DBC");

in the code. But that always resolves to the same numerical address, and converting from two strings, to two trytes, to one integer was pretty slow. In fact, so slow it was a major bottleneck. So, instead, I just statically compute the integer value of "DADDBC", and use it as an argument for memref instead.


05 Mar 2008 15:46
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
I checked out last version and it does not look working...

P.S. What is operation CAD?


06 Mar 2008 18:57
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
That's strange. I re-checked-out the entire source tree, it compiled and ran just fine. Could be an issue with the new UI I guess, try copying share/bg.png to /usr/local/share/tunguska/bg.png

CAD is Compare ADdress. It sets the G flag according to the difference between X,Y and the specified address. Example:

LAD some_address
CAD some_other_address
JEQ some_label ; some_address is equal to some_other_address
JNE some_other_label ; not equal


07 Mar 2008 03:10
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
eudoxie wrote:
That's strange. I re-checked-out the entire source tree, it compiled and ran just fine. Could be an issue with the new UI I guess, try copying share/bg.png to /usr/local/share/tunguska/bg.png


Background is loaded fine. Then it prints border and HELP message, but no prompt - I can't enter anything!
I tried to build it under Linux (GCC 3.4.6 and SDL 1.2.11) and under Windows (using CYGWIN) - the same results.


07 Mar 2008 05:36
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Odd. I've added a testcase in the latest CVS version. Run "tunguska -e", and see if you get any unexpected values.

If that doesn't work, try commenting out

floppy->heartbeat() at line 113 in tunguska.cc
or
agd->heartbeat(*m) at line 115 in tunguska.cc

And see if that does anything...


07 Mar 2008 12:09
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
It doesn't help...

Code:
> tunguska -e

'bg.bmp' not found in '/usr/local/share/tunguska/'
Falling back to 'share/bg.bmp' ... success!
Tunguska loaded null memory, basically
rendering it a drooling vegetable :-(

It's a lot more fun with something in the
memory to execute...Running testcase
't = 10' => 10 (expect 10)
't = t+10' => 20 (expect 20)
't = -365' => 364 (expect 364)
't = 365' => -364 (expect -364)
't = 5; t = t * 2' => 10 (expect 10)
't = 5; t = t / 2' => 2 (expect 2)
't = 5; t = t % 3' => 2 (expect 2)
'm.memref(25) = 10; m.memref(0, 25) += 5' => 15 (expect 15)
'm.memref("DDD", "DDD") = 10; m.memref(-729*729/2) += 5' => 15 (expect 15)
't = 1000; t.to_int();' => 271 (expect 271)
't = -1000; t.to_int();' => -271 (expect -271)
Initial benchmark: 67.935 thousand operations per second


07 Mar 2008 16:36
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Hm. I have an idea, try isolating when the problem occurred by running cvs with the "-D" parameter.

Like this:

cvs [the usual sourceforge stuff] -D "4 days ago" co tunguska_sources


07 Mar 2008 16:47
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
eudoxie wrote:
Hm. I have an idea, try isolating when the problem occurred by running cvs with the "-D" parameter.

Like this:

cvs [the usual sourceforge stuff] -D "4 days ago" co tunguska_sources


I checked out both sources folders with different -D and found that

-D "2008-03-05 13:00" returns working code
-D "2008-03-05 14:00" returns NOT working code

P.S. time is probably shifted to my time zone -0500


07 Mar 2008 18:39
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Could you run

cvs [... sourceforge stuff ...] co -D "2008-03-05 14:00" -P tunguska_sources
cd tunguska_sources
cvs diff -D "2008-03-05 13:00"

And paste the results here?


08 Mar 2008 03:38
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
Code:
Index: Makefile
===================================================================
RCS file: /cvsroot/tunguska/tunguska_sources/Makefile,v
retrieving revision 1.7
retrieving revision 1.8
diff -r1.7 -r1.8
7,8c7,8
< tunguska: trit.o tryte.o machine.o tunguska.o display.o keyboard.o interrupt.o disk.o coprocessor.o
<    g++ trit.o tryte.o machine.o tunguska.o interrupt.o display.o keyboard.o disk.o coprocessor.o -o tunguska ${LDFLAGS}
---
> tunguska: trit.o tryte.o machine.o tunguska.o display.o keyboard.o interrupt.o disk.o agdp.o
>    g++ trit.o tryte.o machine.o tunguska.o interrupt.o display.o keyboard.o disk.o agdp.o -o tunguska ${LDFLAGS}
Index: disk.cc
===================================================================
RCS file: /cvsroot/tunguska/tunguska_sources/disk.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -r1.9 -r1.10
46c46,47
<    tryte &d = m->memref("DDD", "DDA");
---
>    static int offset = tryte::word_to_int("DDD", "DDA");
>    tryte &d = m->memref(offset);
Index: display.cc
===================================================================
RCS file: /cvsroot/tunguska/tunguska_sources/display.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -r1.9 -r1.10
101c101,103
<    tryte displaytryte = m.memref("DDD", "DDB");
---
>    static int displaymem = tryte::word_to_int("DDD", "DDB");
>
>    tryte displaytryte = m.memref(displaymem);
110c112
<    if(refresh == 1) { m.memref("DDD", "DDB")[5] = 0; }
---
>    if(refresh == 1) { m.memref(displaymem)[5] = 0; }
Index: machine.cc
===================================================================
RCS file: /cvsroot/tunguska/tunguska_sources/machine.cc,v
retrieving revision 1.13
retrieving revision 1.15
diff -r1.13 -r1.15
74c74,75
<    STRTOOPC(LAD); STRTOOPC(BIT); STRTOOPC(BLT); STRTOOPC(BLS);
---
>    STRTOOPC(LAD); STRTOOPC(BIT); STRTOOPC(PGT); STRTOOPC(PGS);
>    STRTOOPC(CAD);
93,94c94,97
<    memref("DDD", "DDD") = i->IRQ();
<    memref("DDD", "DDC") = i->data();
---
>    static int memirq = tryte::word_to_int("DDD", "DDD");
>    static int memirqdata = tryte::word_to_int("DDD", "DDC");
>    memref(memirq) = i->IRQ();
>    memref(memirqdata) = i->data();
119c122,123
<    if((CL > memref("444", "441")) == 1) CL = 0;
---
>    static int moffset = tryte::word_to_int("444", "441");
>    if((CL > memref(moffset)) == 1) CL = 0;
261,262c265,267
<       case BLT: blt(arg); break;
<       case BLS: bls(arg); break;
---
>       case PGT: pgt(arg); break;
>       case PGS: pgs(arg); break;
>       case CAD: cad(abs1, abs2); break;
455a461,471
> /* Compare ADdress */
> void machine::cad(const tryte* t, const tryte* t2) {
>    int V =  tryte::word_to_int(*t, *t2);
>    int V2 = tryte::word_to_int(X, Y);
>
>    int diff = V - V2;
>    if(diff != 0) diff = diff / abs(diff);
>
>    pflag(diff);
> }
>
464c480
< void machine::blt(const tryte* t) {
---
> void machine::pgt(const tryte* t) {
474c490
< void machine::bls(const tryte* t) {
---
> void machine::pgs(const tryte* t) {
Index: machine.h
===================================================================
RCS file: /cvsroot/tunguska/tunguska_sources/machine.h,v
retrieving revision 1.7
retrieving revision 1.9
diff -r1.7 -r1.9
61c61
<          IVC, PRM, TSH, BUT, LAD, BLT, BLS
---
>          IVC, PRM, TSH, BUT, LAD, PGT, PGS, CAD
167,168c167,170
<       void blt(const tryte* t);
<       void bls(const tryte* t);
---
>       void cad(const tryte* t, const tryte* t2);
>
>       void pgt(const tryte* t);
>       void pgs(const tryte* t);
Index: tunguska.cc
===================================================================
RCS file: /cvsroot/tunguska/tunguska_sources/tunguska.cc,v
retrieving revision 1.13
retrieving revision 1.15
diff -r1.13 -r1.15
26c26
< #include "coprocessor.h"
---
> #include "agdp.h"
35c35
< #define POLL_INTERVAL 5000
---
> #define POLL_INTERVAL 10000
69c69
<       coprocessor* cop) {
---
>       agdp* agd) {
114c114
<       cop->heartbeat(*m);
---
>       agd->heartbeat(*m);
117c117
< }
---
>    }
155c155
<    coprocessor* cop = new coprocessor();
---
>    agdp* agd= new agdp();
192c192
<       cycle(m, disp, floppy, keyboard, cop);
---
>       cycle(m, disp, floppy, keyboard, agd);
204c204
<       cycle(m, disp, floppy, keyboard, cop);
---
>       cycle(m, disp, floppy, keyboard, agd);

Index: ram.asm
===================================================================
RCS file: /cvsroot/tunguska/tunguska_memory_image_sources/ram.asm,v
retrieving revision 1.20
retrieving revision 1.21
diff -r1.20 -r1.21
236c236
<       BLS   #%DDD
---
>       PGS   #%DDD
277c277
<       BLS   #%DDD
---
>       PGS   #%DDD
Index: stdlib.asm
===================================================================
RCS file: /cvsroot/tunguska/tunguska_memory_image_sources/stdlib.asm,v
retrieving revision 1.6
retrieving revision 1.7
diff -r1.6 -r1.7
627a628
>


08 Mar 2008 06:22
Profile WWW
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
When I changed in current code
static int moffset = tryte::word_to_int("444", "441");
to
int moffset = tryte::word_to_int("444", "441");
it bacames working again!

P.S. Probably you need to put all this kind of constants as class members and initialize them in constructors, because it looks like optimization mistake of compiler (you use -O3) or something like this...


08 Mar 2008 06:33
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Okay, try the latest CVS. I've worked around the static variable approach with compiler macros instead. That should be as fast, or even faster than static variables, since it allows the compiler to "understand" them better.

Also, what sort of speeds does the benchmark give you. I saw you post earlier with a really slow speed. It should be at least in the range 250+ on a reasonably fast computer...


08 Mar 2008 08:04
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
Yes, it's working now!
But scrolling looks strange
And I have benchmark 349 now


08 Mar 2008 09:26
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Can you elaborate, how does the scrolling look?


08 Mar 2008 14:07
Profile
Online
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22606
Location: Silicon Valley
Reply with quote
eudoxie wrote:
Can you elaborate, how does the scrolling look?


Before scrolling:

Image

Scrolling in progress:

Image

Result looks fine (except broken lines):

Image


08 Mar 2008 16:58
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 273 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 19  Next

Who is online

Users browsing this forum: No registered users and 26 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.