From d8a05c72bd13e379975226882c459856ecbcf035 Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Sat, 19 Nov 2016 19:15:16 +0100 Subject: [PATCH] =?UTF-8?q?MMIX=202009=20=E2=80=94=20Release=202016-08-04.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README | 13 +++++++------ abstime.w | 2 +- fsubtest.mms | 5 +++++ mmix-pipe.w | 19 +++++++++++++++++-- mmmix.w | 31 +++++++++++++++++++++---------- 5 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 fsubtest.mms diff --git a/README b/README index e754a51..2840942 100644 --- a/README +++ b/README @@ -67,12 +67,13 @@ makefile.dos DOS makefile (for DOS/Windows platforms) HOW TO GET STARTED First try "make doc"; this, at least on UNIX-like systems equipped with dvips, -should create three PostScript documents called mmix-doc.ps, mmixal.ps, and -mmix-sim.ps. Print these files, and move their tables-of-contents -pages to the front (those pages appear at the end). Read the introductory -parts of those documents, and please report any errors you find to -knuth-bug@cs.stanford.edu. If your system is unable to create those documents -for some reason, go to +should create three PostScript documents called mmix-doc.ps, mmixal-intro.ps, +and mmix-sim-intro.ps. Print these files, and move each table-of-contents +page to the front (those pages appear at the end). Read those documents, +and please report any errors you find to ruckert@cs.hm.edu. +If your system is unable to create those documents for some reason, go to + http://mmix.cs.hm.edu/doc +for pdf files, or to http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html and download the compressed PostScript files from there. Say "make clean" when you've got hardcopy. diff --git a/abstime.w b/abstime.w index 6605ba1..50d6aa9 100644 --- a/abstime.w +++ b/abstime.w @@ -18,7 +18,7 @@ hold more than 32 bits. #include #include @# -int main() +main() { printf("#define ABSTIME %ld\n",time(NULL)); return 0; diff --git a/fsubtest.mms b/fsubtest.mms new file mode 100644 index 0000000..c64ffe7 --- /dev/null +++ b/fsubtest.mms @@ -0,0 +1,5 @@ +A GREG #00f0000000000000 +B GREG #1716 + LOC #100 +Main FSUB $0,A,B + TRAP 0,Halt,0 diff --git a/mmix-pipe.w b/mmix-pipe.w index 978b9ee..2fa11ec 100644 --- a/mmix-pipe.w +++ b/mmix-pipe.w @@ -205,11 +205,16 @@ bypass the library names here. |MMIX_config()| has done its work but before the simulator starts to execute any programs. Then |MMIX_run()| can be called as often as the user likes. +The |MMIX_silent()| routine is a noninteractive variant of |MMIX_run()|: +It will return the value of register |g[255].l| when executing a +\.{TRAP} \.{0,Halt,0} instruction. + @s octa int @= Extern void MMIX_init @,@,@[ARGS((void))@]; Extern void MMIX_run @,@,@[ARGS((int cycs, octa breakpoint))@]; +Extern int MMIX_silent @,@,@[ARGS((void))@]; @ @= void MMIX_init() @@ -218,6 +223,16 @@ void MMIX_init() @; } @# +int MMIX_silent() +{ + octa breakpoint; + @; + while (true) { + @; + if (halted) return specval(&g[255]).o.l; + } +} +@# void MMIX_run(cycs,breakpoint) int cycs; octa breakpoint; @@ -3595,7 +3610,7 @@ static void flush_cache(c,p,keep) else d=c->outbuf.data, c->outbuf.data=p->data, p->data=d; dd=c->outbuf.dirty, c->outbuf.dirty=p->dirty, p->dirty=dd; for (j=0;jbb>>c->g;j++) p->dirty[j]=false; - c->outbuf.rank=c->bb; /* this many valid bytes */ + p->rank=c->bb; /* this many valid bytes */ startup(&c->flusher,c->copy_out_time); /* will not be aborted */ } @@ -3636,7 +3651,7 @@ static cacheblock* alloc_slot(c,alf) register cacheblock *p,*q; if (cache_search(c,alf)) return NULL; if (c->flusher.next && c->outbuf.tag.h==alf.h && - !((c->outbuf.tag.l^alf.l)&c->tagmask)) return NULL; + !((c->outbuf.tag.l^alf.l)&-c->bb)) return NULL; s=cache_addr(c,alf); /* the set corresponding to |alf| */ if (c->victim) p=choose_victim(c->victim,c->vv,c->vrepl); else p=choose_victim(s,c->aa,c->repl); diff --git a/mmmix.w b/mmmix.w index eb197d0..1a7c397 100644 --- a/mmmix.w +++ b/mmmix.w @@ -22,7 +22,7 @@ do the actual work after this module has told them what to do. @ A user typically invokes the meta-simulator with a \UNIX/-like command line of the general form -`\.{mmmix}~\.{configfile}~\.{progfile}', +`\.{mmmix} \.{options}~\.{configfile}~\.{progfile}', where the \.{configfile} describes the characteristics of an \MMIX\ implementation and the \.{progfile} contains a program to be downloaded and run. Rules for configuration files appear in @@ -32,6 +32,9 @@ ASCII text file that describes hexadecimal data in a rudimentary format. It is assumed to be binary if its name ends with the extension `\.{.mmb}'. +The only command-line option currently supported is \.{-s}, which will run the +simulator silently until a \.{TRAP} \.{0,Halt,0} instruction is executed. + @c #include #include @@ -51,24 +54,31 @@ int main(argc,argv) MMIX_init(); mmix_io_init(); @; - @; - printf("Simulation ended at time %d.\n",ticks.l); - print_stats(); - return 0; + if (silent) return MMIX_silent(); + else { + @; + printf("Simulation ended at time %d.\n",ticks.l); + print_stats(); + return 0; + } } -@ The command line might also contain options, some day. +@ The command line might also contain additional options, some day. For now I'm forgetting them and simplifying everything until I gain further experience. @= -if (argc!=3) { - fprintf(stderr,"Usage: %s configfile progfile\n",argv[0]); +for (n=1;argv[n]!=NULL && argv[n][0]=='-';n++) { + if (argv[n][1]=='s') silent=true; + else argc=0; /* unknown option */ +} +if (argc!=n+2) { + fprintf(stderr,"Usage: %s [-s] configfile progfile\n",argv[0]); @.Usage: ...@> exit(-3); } -config_file_name=argv[1]; -prog_file_name=argv[2]; +config_file_name=argv[argc-2]; +prog_file_name=argv[argc-1]; @ @= if (strlen(prog_file_name)>4 && @@ -543,6 +553,7 @@ case '!':@+ { register int j; continue; @ @= +bool silent=false; bool bad_address; extern bool page_bad; extern octa page_mask;