games/mix: document -g option, rename tests to examples as it is in the man page

This commit is contained in:
spew 2017-01-17 20:51:08 -06:00
parent ca47fef006
commit 4b68ddfb5a
5 changed files with 99 additions and 2 deletions

View file

@ -6,6 +6,9 @@ assembler and emulator
.SH SYNOPSIS
.B games/mix
[
.B -g
]
[
.I file ...
]
.SH DESCRIPTION
@ -18,7 +21,11 @@ architecture. The command assembles the named
files into memory and then presents a command
prompt to control an emulated
.B MIX
machine.
machine. The
.B -g
option causes the emulator immediately to run a complete assembled
.B MIX
program and exits the emulator when the emulator halts.
.PP
The following commands are accepted:
.TP

View file

@ -0,0 +1,14 @@
# Entry condition R1 = n.
# Exit: RA = max R2 = index of max in X
X EQU 1000
ORIG 3000
MAXIMUM STJ EXIT # Subroutine linkage.
INIT ENT3 0,1 # M1. Initialize k n.
JMP CHANGEM # j n, m X[n], k n-1.
LOOP CMPA X,3 # M3. Compare.
JGE *+3 # To M5 if m X[k].
CHANGEM ENT2 0,3 # M4. Change m. j k.
LDA X,3 # m X[k].
DEC3 1 # M5. Decrease k.
J3P LOOP # M2. All tested? To M3 if k > 0.
EXIT JMP * # Return to main program.

View file

@ -0,0 +1,25 @@
ORIG X
CON 0
CON 3910
CON 23
CON -45
CON 310
CON 475
CON 40291
CON 358
CON 20912
RESULT ALF "MAX: "
CON 0
ALF " AT: "
CON 0
ORIG EXIT+1
MAIN ENT1 RESULT-X-1
JMP MAXIMUM
CHAR
STX RESULT+1
ENTA ,2
CHAR
STX RESULT+3
OUT RESULT(19)
HLT
END MAIN

View file

@ -0,0 +1,49 @@
L EQU 500
PRINTER EQU 18
PRIME EQU -1
BUF0 EQU 2000
BUF1 EQU BUF0+25
ORIG 3000
START IOC 0(PRINTER)
LD1 =1-L=
LD2 =3=
2H INC1 1
ST2 PRIME+L,1
J1Z 2F
4H INC2 2
ENT3 2
6H ENTA 0
ENTX 0,2
DIV PRIME,3
JXZ 4B
CMPA PRIME,3
INC3 1
JG 6B
JMP 2B
2H OUT TITLE(PRINTER)
ENT4 BUF1+10
ENT5 -50
2H INC5 L+1
4H LDA PRIME,5
CHAR
STX 0,4(1:4)
DEC4 1
DEC5 50
J5P 4B
OUT 0,4(PRINTER)
LD4 24,4
J5N 2B
HLT
ORIG PRIME+1
CON 2
ORIG BUF0-5
TITLE ALF "FIRST"
ALF " FIVE"
ALF " HUND"
ALF "RED P"
ALF "RIMES"
ORIG BUF0+24
CON BUF1+10
ORIG BUF1+24
CON BUF0+10
END START

View file

@ -211,7 +211,7 @@ repl(int go)
Binit(&bin, 0, OREAD);
if(go) {
if(go && vmstart != -1) {
once = 0;
goto Go;
}
@ -277,6 +277,8 @@ repl(int go)
vmstart = mixvm(vmstart, once);
else
break;
if(go)
exits(nil);
if(vmstart == -1)
print("halted\n");
else