; d1tables.asm -- Midas/D1 machine description tables
;	Last edited: 21 July 1980

.get "d1regmem.d"

; MMPGRN
.bext RDatatoCSS,MDatatoCSS,BadAltIn

; D1MICRES
.bext MPrintMSTAT,MPrintUPTIME

; D1PRIN1
.bext PrintIM

; D1PRIN2
.bext PrintTLINK,PrintAATOVA,PrintIFUM,PrintD1OUT,PrintShC,PrintSTKP
.bext PrintWrdByt,PrintPCX,PrintMADDR,PrintBR

; D1PRIN3
.bext PrintDMUX,PrintMCR,PrintESTAT

; D1PRIN3W
.bext PrintTIOA,PrintMEMBASE,PrintTASK

; D1PRIN3X
.bext PrintALUFM

; D1PRIN5
.bext PrintCONFIG,PrintCACHEA,PrintROW,PrintMAP,PrintPIPE,PrintINSSET

; D1PRINMIC
.bext PrintMSTAT,PrintABSOL

; D1TYPEIN
.bext InstructionIn,WrdBytIn

; Defined here
.bextz MEMNAM,MEMFORMS,MEMWID,MEMLEN,MEMCON,NMEMS
.bext AltMForms,AltMInput
.bextz REGNAM,REGFORMS,REGWID,REGCON,NREGS
.bext AltRForms,AltRInput

.txtm B

.srel

AltMForms:	.AltMForms
AltRForms:	.AltRForms
AltMInput:	.AltMInput
AltRInput:	.AltRInput

.zrel

; Order registers and memories in the following tables so that TestAll
; will test the most basic ones first.

MEMNAM:		.MName
MEMFORMS:	.MForm
MEMLEN:		.MLen
MEMWID:		.MWid
MEMCON:		.MCon
NMEMS:		.MCon-.MWid

REGNAM:		.RName
REGFORMS:	.RForm
REGWID:		.RWid
REGCON:		.RCon
NREGS:		.RCon-.RWid

.nrel

; *Note that the tables must be in the order given here because of*
; *the length error checks in MInit0().*
.RName:	CPREGn-.
	MIRn-.
	IMOUTn-.
	Qn-.
	CNTn-.
	SHCn-.
	MEMBXn-.
	STKPn-.
	TASKn-.
	PROCSRNn-.
	MCRn-.
	CONFIGn-.
	PCXn-.
	INSSETn-.
	TESTSYNn-.
	STROBEn-.
	D1OUTn-.
	UPTIMEn-.
	TGLITCHn-.
	EVCNTAn-.
	EVCNTBn-.
	AATOVAn-.
	ESTATn-.

.RForm:	0		; CPREG
	FormIMa-.	; MIR
	FormIMa-.	; IMOUT
	0		; Q
	0		; CNT
	0		; SHC
	0		; MEMBX
	FormSTKP-.	; STKP
	FormTASK-.	; TASK
	0		; PROCSRN
	0		; MCR
	0		; CONFIG
	0		; PCX
	FormINSSET-.	; INSSET
	0		; TESTSYN
	FormSTROBE-.	; STROBE
	FormD1OUT-.	; D1OUT
	FormUPTIME-.	; UPTIME
	FormUPTIME-.	; TGLITCH
	0		; EVCNTA
	0		; EVCNTB
	FormIMAddr-.	; AATOVA
	0		; ESTAT

.RWid:	20		; CPREG
	44		; MIR
	44		; IMOUT
	20		; Q
	20		; CNT
	20		; SHC
	 2		; MEMBX
	12		; STKP
	 4		; TASK
	 4		; PROCSRN
	20		; MCR
	20		; CONFIG
	20		; PCX
	 5		; INSSET
	20		; TESTSYN
	20		; STROBE
	20		; D1OUT
	60		; UPTIME
	60		; TGLITCH
	20		; EVCNTA
	20		; EVCNTB
	20		; AATOVA
	20		; ESTAT

; **See MRType structure in MCommon.D**
; Bit 0 = value can be accessed when machine is running; read is ok
;	if passive-read bit is set, write ok if passive-write bit set
; Bit 1 = defined (= can be examined on the display)
; Bit 2 to 4 = --
; Bit 5 = can be read passively
; Bit 6 = read-only
; Bit 7 = can be written passively
; Bit 10 = look for symbols with SearchBlocks (memories only)
; Bit 11-12 = default radix (0=octal, 1=decimal, 2=hex)
; Bit 13-14 = default display mode (0=numeric, 1=SearchBlocks, 2=symbolic)
; Bit 15 = automatic prettyprint
; Bit 16 = always read value and update display if necessary
; Bit 17 = tested in "Test-All"
.RCon:	140401		; CPREG
	 42405		; MIR
	 42400		; IMOUT (read-only unless DMuxSelect eq DChecked)
	 40001		; Q
	 40001		; CNT
	 40005		; SHC
	 40001		; MEMBX
	 40001		; STKP
	 42001		; TASK
	 40001		; PROCSRN
	 42005		; MCR
	 41000		; CONFIG
	 41004		; PCX
	 40001		; INSSET (insset bits writeable, idcnt bits aren't)
	 42000		; TESTSYN
	 42404		; STROBE
	 42404		; D1OUT
	143022		; UPTIME
	143022		; TGLITCH
	 41000		; EVCNTA (read-only)
	 40001		; EVCNTB
	142404		; AATOVA
	 42404		; ESTAT

.AltRForms:
	RDatatoCSS	; CPREG
	PrintIM		; MIR
	PrintIM		; IMOUT
	PrintWrdByt	; Q
	PrintWrdByt	; CNT
	PrintShC	; SHC
	RDatatoCSS	; MEMBX
	PrintSTKP	; STKP
	PrintTASK	; TASK
	RDatatoCSS	; PROCSRN
	PrintMCR	; MCR
	PrintCONFIG	; CONFIG
	PrintPCX	; PCX
	PrintINSSET	; INSSET
	RDatatoCSS	; TESTSYN
	PrintD1OUT	; STROBE
	PrintD1OUT	; D1OUT
	RDatatoCSS	; UPTIME
	RDatatoCSS	; TGLITCH
	RDatatoCSS	; EVCNTA
	RDatatoCSS	; EVCNTB
	PrintAATOVA	; AATOVA
	PrintESTAT	; ESTAT

.AltRInput:
	BadAltIn	; CPREG
	InstructionIn	; MIR
	BadAltIn	; IMOUT
	WrdBytIn	; Q
	WrdBytIn	; CNT
	WrdBytIn	; SHC
	BadAltIn	; MEMBX
	BadAltIn	; STKP
	BadAltIn	; TASK
	BadAltIn	; PROCSRN
	BadAltIn	; MCR
	BadAltIn	; CONFIG
	BadAltIn	; PCX
	BadAltIn	; INSSET
	BadAltIn	; TESTSYN
	BadAltIn	; STROBE
	BadAltIn	; D1OUT
	BadAltIn	; UPTIME
	BadAltIn	; TGLITCH
	BadAltIn	; EVCNTA
	BadAltIn	; EVCNTB
	BadAltIn	; AATOVA
	BadAltIn	; ESTAT

.MName:	ABSOLn-.
	TPCn-.
	TLINKn-.
	OLINKn-.
	IMBDn-.
	IMn-.
	IMXn-.
	ALUFMn-.
	Tn-.
	RBASEn-.
	TIOAn-.
	MEMBASEn-.
	RMn-.
	STKn-.
	PIPEn-.
	BRn-.
	CACHEAn-.
	CACHEDn-.
	MAPn-.
	VMn-.
	IFUMn-.
	LDRn-.
	MDATAn-.
	MADDRn-.
	DMUXn-.
	DHISTn-.
	VHn-.
	MDn-.
	TASKNn-.
	DEVICEn-.
	STKXn-.
	MSTATn-.
	ABSn-.
	ROWn-.
	BRXn-.

.MForm:	0		; $ABSOLUTE
	FormIMAddr-.	; TPC
	FormIMAddr-.	; TLINK
	FormIMAddr-.	; OLINK
	FormIMa-.	; IMBD (direct outputs)
	FormIMv-.	; IM (virtual)
	FormIMa-.	; IMX (absolute)
	0		; ALUFM
	0		; T
	0		; RBASE
	FormTIOA-.	; TIOA
	FormMEMBASE-.	; MEMBASE
	0		; RM
	0		; STK
	FormPIPE-.	; PIPE
	FormBR-.	; BR
	FormCACHEA-.	; CACHEA
	0		; CACHED
	FormMAP-.	; MAP
	0		; VM
	FormIFUM-.	; IFUM
	FormIMa-.	; LDR
	FormIMa-.	; MDATA
	Form32-.	; MADDR
	0		; DMUX
	FormDH-.	; DHIST
	Form32-.	; VH
	0		; MD
	0		; TASKN
	0		; DEVICE
	0		; STKX
	FormMSTAT-.	; MSTAT
	FormABS-.	; $ABS
	FormROW-.	; ROW
	FormBRX-.	; BRX

.MLen:	     1	; $ABSOLUTE
	     0
	     0	; TPC
	NTasks
	     0	; TLINK
	NTasks
	     0	; OLINK
	NTasks
	     0	; IMBD (direct outputs)
	 IMlen
	     0	; IM (virtual)
	 IMlen
	     0	; IMX (absolute)
	 IMlen
	     0	; ALUFM
	    20
	     0	; T
	NTasks
	     0	; RBASE
	NTasks
	     0	; TIOA
	NTasks
	     0	; MEMBASE
	NTasks
	     0	; RM
	 RMlen
	     0	; STK
	   400
	     0	; PIPE
	    20
	     0	; BR
	 BRlen
	     0	; CACHEA ("FixForConfig" fills this in)
	     0
	     0	; CACHED ("FixForConfig")
	     0
	     0	; MAP ("FixForConfig")
	     0
	     0	; VM ("FixForConfig")
	     0
	     0	; IFUM
	  2000
	     0	; LDR
	LDRlen
	     0	; MDATA
	MDATAlen
	     0	; MADDR
	MADDRlen
	     0	; DMUX
	DMUXlen
	     0	; DHIST
	DHISTlen
	     0	; VH
	DHISTlen
	     0	; MD
	NTasks
	     0	; TASKN
	NTasks
	     0	; DEVICE
	DEVICElen
	     0	; STKX
	    77
	     0	; MSTAT
	    24
	     0	; $ABS
	100000
	     0	; ROW ("FixForConfig")
	     0
	     0	; BRX
	     4

.MWid:	10	; $ABSOLUTE
	20	; TPC
	20	; TLINK
	20	; OLINK
	44	; IMBD (direct outputs)
	100	; IM (virtual)
	44	; IMX (absolute)
	10	; ALUFM
	20	; T
	 4	; RBASE
	10	; TIOA
	 5	; MEMBASE
	20	; RM
	20	; STK
	40	; PIPE
	40	; BR
	40	; CACHEA
	20	; CACHED
	40	; MAP
	20	; VM
	40	; IFUM
	44	; LDR
	MDATAwid	; MDATA
	40	; MADDR
	20	; DMUX
	54	; DHIST
	40	; VH
	20	; MD
	20	; TASKN
	20	; DEVICE
	20	; STKX
	40	; MSTAT
	20	; $ABS
	40	; ROW
	40	; BRX

; Bit 0 = value can be accessed when machine is running; read is ok if
;	passive-read is also true, write ok if passive-write is true.
; Bit 1 = defined (can be examined on the display)
; Bit 2 = flush symbols in "Load" or "Dump" (Symbols in fake memories used
;	only as artifacts of the assembly are treated this way.)
; Bit 3 = retain symbol even in "LdData"
; Bit 4 = has parity (appears in PE-scan menu)
; Bit 5 = can be read passively
; Bit 6 = read-only
; Bit 7 = can be written passively
; Bit 10 = look for symbols with SearchBlocks
; Bit 11-12 = default radix (0=octal, 1=decimal, 2=hex)
; Bit 13-14 = default display mode (0=numeric, 1=SearchBlocks, 2=symbolic)
; Bit 15 = prettyprint new value on A+1/A-1 and SetValue actions
; Bit 16 = always read value and update display
; Bit 17 = tested by "Test-All"
.MCon:	152700	; $ABSOLUTE (hex)
	 40005	; TPC
	 40005	; TLINK
	 41004	; OLINK
	 42004	; IMBD (direct outputs for testing)
	 40204	; IM (virtual)
	 44005	; IMX (absolute)
	 40005	; ALUFM
	 40001	; T (Can't PEscan because T smashed everywhere)
	 40001	; RBASE
	 40005	; TIOA
	 40001	; MEMBASE
	 44201	; RM
	 44001	; STK
	 41000	; PIPE
	 40201	; BR
	 44001	; CACHEA
	 44001	; CACHED
	 44000	; MAP
	 40000	; VM
	 44004	; IFUM
	142604	; LDR
	152600	; MDATA
	152600	; MADDR (see HWAlwaysUpdate in D1Res.bcpl)
	 52600	; DMUX (read-only unless DMuxSelect eq DChecked)
	 42400	; DHIST
	 43000	; VH
	 41000	; MD
	 40200	; TASKN
	 40200	; DEVICE
	 40000	; STKX
	153322	; MSTAT
	152700	; $ABS
	 40000	; ROW
	 40200	; BRX

.AltMForms:
	PrintABSOL	; $ABSOLUTE
	PrintTLINK	; TPC
	PrintTLINK	; TLINK
	PrintTLINK	; OLINK
	PrintIM		; IMBD
	PrintIM		; IM
	PrintIM		; IMX
	PrintALUFM	; ALUFM
	PrintWrdByt	; T
	MDatatoCSS	; RBASE
	PrintTIOA	; TIOA
	PrintMEMBASE	; MEMBASE
	PrintWrdByt	; RM
	PrintWrdByt	; STK
	PrintPIPE	; PIPE
	PrintBR		; BR
	PrintCACHEA	; CACHEA
	PrintWrdByt	; CACHED
	PrintMAP	; MAP
	PrintWrdByt	; VM
	PrintIFUM	; IFUM
	PrintIM		; LDR
	MDatatoCSS	; MDATA
	PrintMADDR	; MADDR
	PrintDMUX	; DMUX
	MDatatoCSS	; DHIST
	MDatatoCSS	; VH
	PrintWrdByt	; MD
	MDatatoCSS	; TASKN
	MDatatoCSS	; DEVICE
	PrintWrdByt	; STKX
	PrintMSTAT	; MSTAT
	PrintWrdByt	; $ABS
	PrintROW	; ROW
	PrintBR		; BRX

.AltMInput:
	BadAltIn	; $ABSOLUTE
	BadAltIn	; TPC
	BadAltIn	; TLINK
	BadAltIn	; OLINK
	InstructionIn	; IMBD
	InstructionIn	; IM
	InstructionIn	; IMX
	BadAltIn	; ALUFM
	WrdBytIn	; T
	BadAltIn	; RBASE
	BadAltIn	; TIOA
	BadAltIn	; MEMBASE
	WrdBytIn	; RM
	WrdBytIn	; STK
	BadAltIn	; PIPE
	BadAltIn	; BR
	BadAltIn	; CACHEA
	WrdBytIn	; CACHED
	BadAltIn	; MAP
	WrdBytIn	; VM
	BadAltIn	; IFUM
	InstructionIn	; LDR
	BadAltIn	; MDATA
	BadAltIn	; MADDR
	WrdBytIn	; DMUX
	BadAltIn	; DHIST
	BadAltIn	; VH
	WrdBytIn	; MD
	BadAltIn	; TASKN
	BadAltIn	; DEVICE
	WrdBytIn	; STKX
	BadAltIn	; MSTAT
	WrdBytIn	; $ABS
	BadAltIn	; ROW
	BadAltIn	; BRX

CPREGn:		.txt "CPREG"
MIRn:		.txt "MIR"
IMOUTn:		.txt "IMOUT"
Qn:		.txt "Q"
CNTn:		.txt "CNT"
SHCn:		.txt "SHC"
MEMBXn:		.txt "MEMBX"
STKPn:		.txt "STKP"
TASKn:		.txt "TASK"
PROCSRNn:	.txt "PROCSRN"
MCRn:		.txt "MCR"
CONFIGn:	.txt "CONFIG"
PCXn:		.txt "PCX"
INSSETn:	.txt "INSSET"
TESTSYNn:	.txt "TESTSYN"
STROBEn:	.txt "STROBE"
D1OUTn:		.txt "D1OUT"
UPTIMEn:	.txt "UPTIME"
TGLITCHn:	.txt "TGLITCH"
EVCNTAn:	.txt "EVCNTA"
EVCNTBn:	.txt "EVCNTB"
AATOVAn:	.txt "AATOVA"
ESTATn:		.txt "ESTAT"

ABSOLn:		.txt "$ABSOLUTE"
TPCn:		.txt "TPC"
TLINKn:		.txt "TLINK"
OLINKn:		.txt "OLINK"
IMBDn:		.txt "IMBD"
IMn:		.txt "IM"
IMXn:		.txt "IMX"
ALUFMn:		.txt "ALUFM"
Tn:		.txt "T"
RBASEn:		.txt "RBASE"
TIOAn:		.txt "TIOA"
MEMBASEn:	.txt "MEMBASE"
RMn:		.txt "RM"
STKn:		.txt "STK"
PIPEn:		.txt "PIPE"
BRn:		.txt "BR"
CACHEAn:	.txt "CACHEA"
CACHEDn:	.txt "CACHED"
MAPn:		.txt "MAP"
VMn:		.txt "VM"
IFUMn:		.txt "IFUM"
LDRn:		.txt "LDR"
MDATAn:		.txt "MDATA"
MADDRn:		.txt "MADDR"
DMUXn:		.txt "DMUX"
DHISTn:		.txt "DHIST"	; Only show in right-most display col.
VHn:		.txt "VH"	; Name short to fit in middle display col.
MDn:		.txt "MD"
TASKNn:		.txt "TASKN"
DEVICEn:	.txt "DEVICE"
STKXn:		.txt "STKX"
MSTATn:		.txt "MSTAT"
ABSn:		.txt "$ABS"
ROWn:		.txt "ROW"
BRXn:		.txt "BRX"

; Format tables are:
; Word 0: if positive, number of word-pairs
;	  if negative, number of extensions followed by self-relative
;	  pointers to format tables with word 0 positive.
; Words 1 and 2: First bit and number of bits
; Words 3 and 4, etc. same as words 1 and 2
; The bits selected by a pair are printed in radix followed by a blank
; then the next group, etc.
; Going backward from the pointer:
; Word -1: MemX used in SearchBlocks DisplayMode (-1 if unmeaningful)
; Word -2: lv Procedure for symbolic DisplayMode (0 if unmeaningful)

	0
	IMx
FormIMAddr:
	1
	0
	20

	0
	-1
FormIMv:
	5
	42	; PE1631 and PE015
	2
	62	; Undef and Emul
	2
	64	; Absolute address
	14
	0	; IM[0:20]
	21
	21	; IM[21:41]
	21

	0
	-1
FormIMa:
	3
	42	; PE1631 and PE015
	2
	0	; IMX[0:20]
	21
	21	; IMX[21:41]
	21

	0
	TASKNx
FormTASK:
	1
	0
	4

	0
	DEVICEx
FormTIOA:
	1
	0
	10

	0
	BRx
FormMEMBASE:
	1
	0
	5

	0
	-1
Form32:	2
	0
	20
	20
	20

	0
	-1
FormDH:	3
	40
	14
	0
	20
	20
	20

	0
	-1
FormMAP:
	3
	12	; MapDirtyb, MapParity, MapPE
	3
	15	; Ref, WP, Dirty
	3
	20	; RP[0:15]
	20

	0
	-1
FormBRX:
FormBR:
	2
	4
	14
	20
	20

	0
	-1
FormCACHEA:
	2
	0	; Dirty, vacant, wp, beingloaded
	4
	7	; VA[7:21] **modified by D1CONFIG**
	17

	0
	-1
FormIFUM:
	4
	21	; PE0ok, PE1ok, PE2ok
	3
	5	; 2A, IFaddr
	13
	20	; Sign
	1
	24	; Length', RBaseB', MemB, TPause', TJump'
	14

	0
	-1
FormINSSET:
	2
	0	; IdCnt
	3
	3	; InsSet
	2

	0
	-1
FormSTROBE:
	2
	0	; Data
	11
	12	; Address
	3

	0
	-1
FormD1OUT:
	3
	11	; Strobe
	1
	0	; Data
	11
	12	; Address
	3

	0
	-1
FormSTKP:
	2
	10	; StkOvf and StkUnd
	2
	0	; STKP
	10

	0
	ABSOLx	; Intended for ZSUBPC and ZPC
FormABS:
	0
	0
	20

	MPrintUPTIME	; Symbolic display mode is default
	-1
FormUPTIME:
	6		; 6 numeric bytes in hex if numeric printout
	0
	10
	10
	10
	20
	10
	30
	10
	40
	10
	50
	10

	MPrintMSTAT
	-1
FormMSTAT:
	4
	0
	10
	10
	10
	20
	10
	30
	10

FormPIPE:
	-3
	Form32-.
	Form32-.
	Form32-.

FormROW:
	-5
	FormCACHEA-.
	FormCACHEA-.
	FormCACHEA-.
	FormCACHEA-.
	FormVNV-.

	0
	-1
FormVNV:
	2
	0
	2
	2
	2

.end