Skip to content

Commit

Permalink
MMIX 2009 — Release 2016-08-04.
Browse files Browse the repository at this point in the history
  • Loading branch information
ascherer committed Nov 19, 2016
1 parent 0b71f56 commit d8a05c7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 19 deletions.
13 changes: 7 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion abstime.w
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ hold more than 32 bits.
#include <stdio.h>
#include <time.h>
@#
int main()
main()
{
printf("#define ABSTIME %ld\n",time(NULL));
return 0;
Expand Down
5 changes: 5 additions & 0 deletions fsubtest.mms
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
A GREG #00f0000000000000
B GREG #1716
LOC #100
Main FSUB $0,A,B
TRAP 0,Halt,0
19 changes: 17 additions & 2 deletions mmix-pipe.w
Original file line number Diff line number Diff line change
Expand Up @@ -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

@<External proto...@>=
Extern void MMIX_init @,@,@[ARGS((void))@];
Extern void MMIX_run @,@,@[ARGS((int cycs, octa breakpoint))@];
Extern int MMIX_silent @,@,@[ARGS((void))@];

@ @<External routines@>=
void MMIX_init()
Expand All @@ -218,6 +223,16 @@ void MMIX_init()
@<Initialize everything@>;
}
@#
int MMIX_silent()
{
octa breakpoint;
@<Local variables@>;
while (true) {
@<Perform one machine cycle@>;
if (halted) return specval(&g[255]).o.l;
}
}
@#
void MMIX_run(cycs,breakpoint)
int cycs;
octa breakpoint;
Expand Down Expand Up @@ -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;j<c->bb>>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 */
}

Expand Down Expand Up @@ -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);
Expand Down
31 changes: 21 additions & 10 deletions mmmix.w
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <stdio.h>
#include <stdlib.h>
Expand All @@ -51,24 +54,31 @@ int main(argc,argv)
MMIX_init();
mmix_io_init();
@<Input the program@>;
@<Run the simulation interactively@>;
printf("Simulation ended at time %d.\n",ticks.l);
print_stats();
return 0;
if (silent) return MMIX_silent();
else {
@<Run the simulation interactively@>;
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.

@<Parse...@>=
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];

@ @<Input the program@>=
if (strlen(prog_file_name)>4 &&
Expand Down Expand Up @@ -543,6 +553,7 @@ case '!':@+ { register int j;
continue;

@ @<Glob...@>=
bool silent=false;
bool bad_address;
extern bool page_bad;
extern octa page_mask;
Expand Down

0 comments on commit d8a05c7

Please sign in to comment.