perm filename MIXSIM.MAC[B,PMP] blob
sn#056169 filedate 1973-07-27 generic text, type T, neo UTF8
TITLE MIXSIM - SIMULATOR FOR THE MIX COMPUTER
SUBTTL ALB 7/19/73
CI=0
T=1
T1=2
T2=3
T3=4
T4=5
I=6
F=7
OP=10
PC=11
M=12
FP=13
FBP=14
RP=15
C=16
IOL=17
.SIGN=1B18
.SIGN=1B18 ;SIGN BIT
.SIGNA==1B19 ;TEMPORARY STORAGE FOR SIGN OF AREG
.SIGNX==1B20 ; AND OF XREG
.OVFLO==1B32 ;OVERFLOW TOGGLE
.LESS==1B33 ;COMPARISON INDICATORS
.EQUAL==1B34 ;ONLY ON IS EVER ON AT ANY TIME
.GREAT==1B35
.CMPID==.LESS!.EQUAL!.GREAT
TMASK==370000 ;TRUNCATION MASK TO 30 BITS
IMASK==377777,,770000 ;TRUNCATION MASK FOR IREG WRITE-ONLY PART
MAXF05=2
MAXF06=5
MAXDEV=22
IREGOP==1B18 ; => (1:3) FIELD IS WRITE-ONLY MEMORY
NOMCHK==1B19 ; => USES M IN A WEIRD WAY
NOFCHK==1B20 ; => USES F IN A WEIRD WAY
.BITS==770000 ; => DEVICE "BUSY" IN JRED-JBUS (I.E. GETSTS)
CHAR0=003636363636 ;FULL WORD OF CHARACTER CODED ZEROES
DEFINE FPOINT<
.XCREF
L==N/10
R==N-<L*10>
N==N+1
.CREF
IFGE <<R-L>!<5-R>>,< POINT <<R-L+1>*6>,(FP),<<R*6>+5> >
IFL <<R-L>!<5-R>>,< Z > >
DEFINE ZERO1<
.XCREF
L==N/10
R==N-<L*10>
N==N+1
.CREF
IFGE <<R-L>!<5-R>>,<
IFE <L>,< EXP <-1B5>!<-1B<71-<R*6>>> >
IFN <L>,< EXP -1B<71-<<R-L+1>*6>> > >
IFL <<R-L>!<5-R>>,< Z > >
DEFINE ZERO2<
.XCREF
L==N/10
R==N-<L*10>
N==N+1
.CREF
IFGE <<R-L>!<5-R>>,< EXP <-1B<35+<L*6>>>&<-1B<R*6+5>> >
IFL <<R-L>!<5-R>>,< Z > >
DEFINE MIXTOA(X)<IRPC X<
EXP "X" >>
SIMLOD: OPEN 0,[EXP 13
SIXBIT /DSK/
XWD 0,BIB]
HALT
OPEN 1,[EXP 0
SIXBIT /DSK/
XWD LOB,0]
HALT
LOOKUP 0,[SIXBIT /TEST/
SIXBIT /MOB/
EXP 0,0]
HALT
ENTER 1,[SIXBIT /TEST/
SIXBIT /OUT/
EXP 0,0]
HALT
SOSG BIB+2
IN 0,
AOSA BIB+1
HALT
MOVE T1,@BIB+1
JUMPGE T1,MIXSIM
SOSG BIB+2
IN 0,
AOSA BIB+1
HALT
MOVE T,@BIB+1
MOVEM T,MIXCOR(T1)
AOBJN T1,.-6
JRST .-15
MIXSIM: ;THE SECOND FEATURE STARTS HERE
CLOSE 0,
RELEAS 0,
MOVE PC,T1
SETZB CI,AREG
MOVE T,[AREG,,AREG+1]
BLT T,ZERO
BEGIN:! JRST .+4
MNOP:!
ENDEX: HLRZ T,OPDISP(OP)
TRZ T,770000
ADDM T,CLOCK
MOVE I,MIXCOR(PC)
CAMN PC,PCSTOP#
JFCL
MOVEI PC,1(PC)
CAILE PC,↑D4000
JRST PCERR ;(?PC OUT OF BOUNDS AT MIXUSR XXXXXX?)
MOVEI FP,I
HLRZ M,I
LDB T,FP.TAB+33
LDB F,FP.TAB+44
LDB OP,FP.TAB+55
TRZE M,770000
MOVNI M,(M)
JUMPE T,MCHECK
CAILE T,6
JRST IERR
MOVE T1,AREG(T)
TLZE T1,.SIGN
MOVNI T1,(T1)
ADD M,T1
MCHECK: MOVE T,OPDISP(OP)
TLNE T,NOMCHK
JRST FCHECK
JUMPL M,MEMERR
CAIL M,↑D4000
JRST MEMERR
FCHECK: TLNE T,NOFCHK
JRST (T)
CAILE F,55
JRST FERR
SKIPN FBP,FP.TAB(F)
JRST FERR
JRST (T)
OPDISP: ;OPCODE DISPATCH TABLE
NOMCHK!NOFCHK!1,,MNOP ;NOP
2,,MADD ;ADD
2,,MS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,TMASK
TLO CI,.OVFLO
MOVEM T,AREG
MOVEM T1,XREG
JRSTF @FENDEX
MDIV: MOVE T,AREG
MOVE T1,XREG
JUMPGE T,.+4
TLZ T,.SIGN
MOVN T,T
SETCA T1,
ASH T1,5
ASHC T,-5
MOVEI FP,MIXCOR(M)
LDB T3,FBP
TDZE T3,FSIGN(F)
MOVN T3,T3
DIV T,T3
JUMPGE T,.+5
MOVN T,T
TLO T,.SIGN
MOVN T1,T1
TLO T1,.SIGN
TLZE T,TMASK
TLO CI,.OVFLO
JOV .-1
MOVEM T,AREG
MOVEM T1,XREG
JRSTF @FENDEX
SPEC: CAILE F,MAXF05
JRST FERR
JRST @.+1(F)
EXP MNUM,MCHAR,MHLT
MNUM: SETZ T,
MOVEI FP,5
MOVE T3,AREG
TLZE T3,.SIGN
TLO CI,.SIGNA
LSH T3,6
SETZB T1,T2
LSHC T2,6
DIVI T1,12
IMULI T,12
ADD T,T2
SOJG FP,.-5
MOVEI FP,5
MOVE T3,XREG
LSH T3,6
SETZB T1,T2
LSHC T2,6
DIVI T1,12
IMULI T,12
ADD T,T2
SOJG FP,.-5
TLZE T,TMASK
TLO CI,.OVFLO
TLZE CI,.SIGNA
TLO T,.SIGN
MOVEM T,AREG
JRSTF @FENDEX
MCHAR: SKIPGE XREG
TLO CI,.SIGNX
MOVE T,AREG
JUMPE T,MCHR.3
TLZE T,.SIGN
TLO CI,.SIGNA
MOVEI FP,5
SETZ T2,
IDIVI T,12
MOVEI T1,36(T1)
LSHC T1,-6
SOJG FP,.-3
LSH T2,-6
MCHR.1: TLZE CI,.SIGNX
TLO T2,.SIGN
MOVEM T2,XREG
JUMPE T,MCHR.4
MOVEI FP,5
SETZ T2,
IDIVI T,12
MOVEI T1,36(T1)
LSHC T1,-6
SOJG FP,.-3
LSH T2,-6
MCHR.2: TLZE CI,.SIGNA
TLO T2,.SIGN
MOVEM T2,AREG
JRSTF @FENDEX
MCHR.3: MOVE T2,[CHAR0]
JRST MCHR.1
MCHR.4: MOVE T2,[CHAR0]
JRST MCHR.2
SHIFTS: JUMPL M,ADRERR
CAILE F,MAXF06
JRST FERR
IMULI M,6
MOVE T,AREG
JRST @.+1(F)
EXP MSLA,MSRA,MSLAX,MSRAX,SHIFTC,SHIFTC
MSLA: ASH T,(M)
TLZ T,TMASK
MOVEM T,AREG
JRSTF @FENDEX
MSRA: TLZE T,.SIGN
TLO CI,.SIGNA
MOVNI M,(M)
LSH T,(M)
TLZE CI,.SIGNA
TLO T,.SIGN
MOVEM T,AREG
JRSTF @FENDEX
MSLAX: MOVE T1,XREG
ASH T1,5
ASHC T,(M)
ASH T1,-5
TLZ T,TMASK
TLZ T1,TMASK
MOVEM T,AREG
MOVEM T1,XREG
JRSTF @FENDEX
MSRAX: TLZE T,.SIGN
TLO CI,.SIGNA
SKIPGE T1,XREG
TLO CI,.SIGNX
MOVNI M,(M)
LSH T1,6
LSHC T,(M)
LSH T1,-6
TLZE CI,.SIGNA
TLO T,.SIGN
TLZE CI,.SIGNX
TLO T1,.SIGN
TLZ T,TMASK
TLZ T1,TMASK
MOVEM T,AREG
MOVEM T1,XREG
JRSTF @FENDEX
SHIFTC: MOVE T1,XREG
IDIVI M,12 ;****FP=M+1
JUMPE FP,ENDEX
CAILE FP,36
JRST SHC.2
CAIN F,5
JRST SHC.3
SHC.1: MOVE T2,T1
MOVE T3,T
ASH T1,5
ASH T3,5
ASHC T,(FP)
ASHC T2,(FP)
TLZ T,TMASK
TLZ T2,TMASK
MOVEM T,AREG
MOVEM T2,XREG
JRSTF @FENDEX
SHC.2: MOVNI FP,-12(FP)
CAIN F,5
JRST SHC.1
SHC.3: MOVNI FP,(FP)
TLZE T,.SIGN
TLO CI,.SIGNA
TLZE T1,.SIGN
TLO CI,.SIGNX
MOVE T2,T1
MOVE T3,T
LSH T1,6
LSH T3,6
LSHC T,-6(FP)
LSHC T2,-6(FP)
TLZE CI,.SIGNA
TLO T3,.SIGN
TLZE CI,.SIGNX
TLO T1,.SIGN
MOVEM T3,AREG
MOVEM T1,XREG
JRSTF
MMOVE: MOVSI T,MIXCOR(M)
SKIPL T1,I1REG
CAIL T1,↑D4000
JRST MMOV.2
MMOV.1: HRRI T,MIXCOR(T1)
MOVEI T1,MIXCOR(M)
ADDI T1,(F)
CAIL T1,MIXTOP
JRST MEMERR
BLT T,(T1)
LSH F,1
ADDM F,CLOCK
JRSTF @FENDEX
MMOV.2: TLZN T1,.SIGN
JRST MEMERR
JUMPE T1,MMOV.1
JRST MEMERR
MLOAD: MOVEI RP,AREG-10(OP)
MOVEI FP,MIXCOR(M)
LDB T,FBP
TDZE T,FSIGN(F)
TLO T,.SIGN
SKIPGE OPDISP(OP)
ANDCM T,[IMASK]
MOVEM T,(RP)
JRST ENDEX
MLOADN: MOVEI RP,AREG-20(OP)
MOVEI FP,MIXCOR(M)
LDB T,FBP
TDOE T,FSIGN(F)
TLZ T,.SIGN
SKIPGE OPDISP(OP)
ANDCM T,[IMASK]
MOVEM T,(RP)
JRST ENDEX
MSTORE: MOVE T,AREG-30(OP)
AND T,FZER1(F)
TLZE T,.SIGN
IOR T,FSIGN(F)
MOVEI FP,MIXCOR(M)
DPB T,FBP
JRST ENDEX
MJBUS: MJRED:
CAIG F,MAXDEV
JRST FERR
SKIPN T,DEVTAB(F)
JRST FERR
MOVSI T,(T)
ADD T,STATX-42(OP)
XCT T
JRST ENDEX
HRRZM PC,JREG
MOVE PC,M
JRST ENDEX
STATX: STATO .BITS
BLOCK 3
STATZ .BITS
JMPS: CAILE F,11
JRST FERR
XCT JTAB.1(F)
JRST ENDEX
HRRZM PC,JREG
MOVE PC,M
JRSTF @FENDEX
JTAB.1: JRST JMPS+4 ;JMP
MOVE PC,M ;JSJ
TLZN CI,.OVFLO ;JOV
TLZE CI,.OVFLO ;JNOV
TLNN CI,.LESS ;JL
TLNN CI,.EQUAL ;JE
TLNN CI,.GREAT ;JG
TLNE CI,.LESS ;JGE
TLNE CI,.EQUAL ;JNE
TLNE CI,.GREAT ;JLE
JMP: CAILE F,5
JRST FERR
MOVE T,AREG-50(OP)
XCT JTAB.2(F)
JRST ENDEX
HRRZM PC,JREG
MOVE PC,M
JRST ENDEX
JTAB.2: JRST JMP.1 ;JN IS SPECIAL
TDNE T,[-1B36] ;JZ
JUMPG T,JMPS+4 ;JP
JRST JMP.2 ;JNN IS SPECIAL
TDNN T,[-1B36] ;JNZ
JUMPLE T,JMPS+4 ;JNP
JMP.1: JUMPGE T,ENDEX
SOSGE T
JRST JMPS+4
JRSTF @FENDEX
JMP.2: JUMPGE T,JMPS+4
SOSGE T
JRSTF @FENDEX
JRST JMPS+4
IDEE: CAILE F,3
JRST FERR
JRST @.+1(F)
EXP MINC,MDEC,MENT,MENN
MINC: HRREI T1,(M)
MOVEI RP,AREG-60(OP)
MOVE T,(RP)
TLZE T,.SIGN
MOVN T,T
ADD T,T1
JUMPE T,MINC.1
JUMPG T,.+3
MOVN T,T
TLO T,.SIGN
TLZE T,TMASK
TLO CI,.OVFLO
SKIPGE OPDISP(OP)
ANDCM T,[IMASK]
MOVEM T,(RP)
JRSTF @FENDEX
MDEC: MOVN T1,M
JRST MINC+1
MINC.1: MOVSI T,.SIGN
ANDM T,(RP)
JRST ENDEX
MENT: SKIPN T,M
JRST MENT.1
JUMPG T,.+3
MOVN T,T
TLO T,.SIGN
TLZE T,TMASK
TLO CI,.OVFLO
MOVEM T,AREG-60(OP)
JRST ENDEX
MENT.1: MOVSI T,.SIGN
AND T,I
MOVEM T,AREG-60(OP)
JRST ENDEX
MENN: SKIPN T,M
JRST MENN.1
JUMPGE T,.+3
MOVN T,T
TLZA T,.SIGN
TLO T,.SIGN
TLZE T,TMASK
TLO CI,.OVFLO
MOVEM T,AREG-60(OP)
JRST ENDEX
MENN.1: MOVSI T,.SIGN
ANDCM T,I
MOVEM T,AREG-60(OP)
JRST ENDEX
MCOMP: TLZ CI,.CMPID
MOVE T1,AREG-70(OP)
AND T1,FZER2(F)
MOVE T2,MIXCOR(M)
AND T2,FZER2(F)
TLZE T1,.SIGN
MOVN T1,T1
TLZE T2,.SIGN
MOVN T2,T2
CAMGE T1,T2
JRST .+5
CAMG T1,T2
TLOA CI,.EQUAL
TLO CI,.GREAT
JRST ENDEX
TLO CI,.LESS
JRST ENDEX
MIOC: CAIE F,22
JRST IOERR
MOVEI C,14
MOVEI IOL,ENDEX
JRST LPUT
MOUT: CAIE F,22
JRST IOERR
CAIL M,↑D4000-30
JRST IOERR
MOVSI T,-30
HRRI T,MIXCOR(M)
MOUT.1: MOVEI T1,5
MOVE T3,(T)
LSH T3,6
MOUT.2: SETZ T2,
LSHC T2,6
MOVE C,MTATAB(T2)
JSP IOL,LPUT
SOJG T1,MOUT.2
AOBJN T,MOUT.1
MOVEI C,15
JSP IOL,LPUT
MOVEI C,12
MOVEI IOL,ENDEX
LPUT: SOSG LOB+2
JRST LPUTBF
LPUTC: IDPB C,LOB+1
JRST (IOL)
LPUTBF: OUT 1,
JRST LPUTC
HALT
FINISH: CLOSE 1,
RELEAS 1,
EXIT
AREG: Z
IREGS:
I1REG: Z
I2REG: Z
I3REG: Z
I4REG: Z
I5REG: Z
I6REG: Z
XREG: Z
JREG: Z
ZERO: 0
CLOCK: Z
FENDEX: EXP <1B6>+ENDEX
BIB: BLOCK 3
LOB: BLOCK 3
ADRERR: HALT
FERR: HALT
IERR: HALT
MEMERR: HALT
MHLT: JRST FINISH
MIN: HALT
IOERR: HALT
PCERR: HALT
FP.TAB: ;BYTE POINTER TABLE FOR MIX FIELDS
N==0
REPEAT 56,< FPOINT >
FZER1: ;CLEAR TABLE FOR A STORE OPERATION
N==0
REPEAT 56,< ZERO1 >
FZER2: ;CLEAR TABLE FOR A COMPARE OPERATION
N==0
REPEAT 56,< ZERO2 >
MTATAB: MIXTOA( ABCDEFGHI?JKLMNOPQR!)
EXP """"
MIXTOA(STUVWXYZ0123456789.)
EXP ",","(",")"
MIXTOA(+-*/=$<>@)
EXP ";"
MIXTOA(:'#%&[]↑??)
FSIGN: EXP 1B30,1B24,1B18,1B12,1B6,1B0
BLOCK 47
DEVTAB: BLOCK MAXDEV+1
MIXCOR: BLOCK ↑D4000
MIXTOP=.-1
END SIMLOD