|
nedoPC.orgElectronics hobbyists community established in 2002 |
|
Tunguska the ternary emulator
Author |
Message |
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
I checked out last version and it does not look working...
P.S. What is operation CAD?
|
06 Mar 2008 18:57 |
|
|
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
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 |
|
|
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
|
07 Mar 2008 16:36 |
|
|
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
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 |
|
|
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
| | | | 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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
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 |
|
|
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
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 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
Yes, it's working now!
But scrolling looks strange
And I have benchmark 349 now
|
08 Mar 2008 09:26 |
|
|
eudoxie
Maniac
Joined: 17 Sep 2012 13:36 Posts: 277 Location: 81.170.128.52
|
Can you elaborate, how does the scrolling look?
|
08 Mar 2008 14:07 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22596 Location: Silicon Valley
|
Before scrolling:
Scrolling in progress:
Result looks fine (except broken lines):
|
08 Mar 2008 16:58 |
|
|
Who is online |
Users browsing this forum: No registered users and 35 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
|
|