First Commit of my working state
[simh.git] / LGP / lgp_defs.h
1 /* lgp_defs.h: LGP simulator definitions
2
3 Copyright (c) 2004-2005, Robert M. Supnik
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of Robert M Supnik shall not be
23 be used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from Robert M Supnik.
25 */
26
27 #ifndef _LGP_DEFS_H_
28 #define _LGP_DEFS_H_ 0
29
30 #include "sim_defs.h" /* simulator defns */
31
32 /* Simulator stop codes */
33
34 #define STOP_STOP 1 /* STOP */
35 #define STOP_IBKPT 2 /* breakpoint */
36 #define STOP_OVF 3 /* overflow */
37 #define STOP_NXDEV 4 /* non-existent device */
38 #define STOP_STALL 5 /* IO stall */
39
40 /* Memory */
41
42 #define MEMSIZE 4096 /* memory size */
43 #define AMASK 0xFFF /* addr mask */
44 #define NTK_30 64
45 #define NSC_30 64
46 #define SCMASK_30 0x03F /* sector mask */
47 #define NTK_21 32
48 #define NSC_21 128
49 #define SCMASK_21 0x07F
50 #define RPM 4000 /* rev/minutes */
51 #define WPS ((NSC_30 * RPM) / 60) /* words/second */
52
53 /* Architectural constants */
54
55 #define SIGN 0x80000000 /* sign */
56 #define DMASK 0xFFFFFFFF /* data mask */
57 #define MMASK 0xFFFFFFFE /* memory mask */
58
59 /* Instruction format */
60
61 #define I_M_OP 0xF /* opcode */
62 #define I_V_OP 16
63 #define I_OP (I_M_OP << I_V_OP)
64 #define I_GETOP(x) (((x) >> I_V_OP) & I_M_OP)
65 #define I_M_EA AMASK /* address */
66 #define I_V_EA 2
67 #define I_EA (I_M_EA << I_V_EA)
68 #define I_GETEA(x) (((x) >> I_V_EA) & I_M_EA)
69 #define I_M_TK 0x3F /* LGP-30 char */
70 #define I_V_TK 8 /* LGP-21 device */
71 #define I_GETTK(x) (((x) >> I_V_TK) & I_M_TK)
72
73 /* Unit flags */
74
75 #define UNIT_V_LGP21 (UNIT_V_UF + 0)
76 #define UNIT_V_MANI (UNIT_V_UF + 1)
77 #define UNIT_V_INPT (UNIT_V_UF + 2)
78 #define UNIT_V_OUTPT (UNIT_V_UF + 3)
79 #define UNIT_V_IN4B (UNIT_V_UF + 4)
80 #define UNIT_V_TTSS_D (UNIT_V_UF + 5)
81 #define UNIT_V_LGPH_D (UNIT_V_UF + 6)
82 #define UNIT_V_FLEX_D (UNIT_V_UF + 7) /* Flex default */
83 #define UNIT_V_FLEX (UNIT_V_UF + 8) /* Flex format */
84 #define UNIT_V_NOCS (UNIT_V_UF + 9) /* ignore cond stop */
85 #define UNIT_LGP21 (1u << UNIT_V_LGP21)
86 #define UNIT_MANI (1u << UNIT_V_MANI)
87 #define UNIT_INPT (1u << UNIT_V_INPT)
88 #define UNIT_OUTPT (1u << UNIT_V_OUTPT)
89 #define UNIT_IN4B (1u << UNIT_V_IN4B)
90 #define UNIT_TTSS_D (1u << UNIT_V_TTSS_D)
91 #define UNIT_LGPH_D (1u << UNIT_V_LGPH_D)
92 #define UNIT_FLEX_D (1u << UNIT_V_FLEX_D)
93 #define UNIT_FLEX (1u << UNIT_V_FLEX)
94 #define UNIT_NOCS (1u << UNIT_V_NOCS)
95 #define Q_LGP21 (cpu_unit.flags & UNIT_LGP21)
96 #define Q_MANI (cpu_unit.flags & UNIT_MANI)
97 #define Q_INPT (cpu_unit.flags & UNIT_INPT)
98 #define Q_OUTPT (cpu_unit.flags & UNIT_OUTPT)
99 #define Q_IN4B (cpu_unit.flags & UNIT_IN4B)
100
101 /* IO return */
102
103 #define IORETURN(f,v) ((f)? (v): SCPE_OK) /* stop on error */
104
105 /* Significant characters */
106
107 #define FLEX_LC 0x04
108 #define FLEX_UC 0x08
109 #define FLEX_CR 0x10
110 #define FLEX_BS 0x14
111 #define FLEX_CSTOP 0x20
112 #define FLEX_DEL 0x3F
113
114 /* LGP-21 device assignments */
115
116 #define DEV_PT 0
117 #define DEV_TT 2
118 #define DEV_MASK 0x1F
119 #define DEV_SHIFT 62
120
121 /* Instructions */
122
123 enum opcodes {
124 OP_Z, OP_B, OP_Y, OP_R,
125 OP_I, OP_D, OP_N, OP_M,
126 OP_P, OP_E, OP_U, OP_T,
127 OP_H, OP_C, OP_A, OP_S
128 };
129
130 /* Prototypes */
131
132 uint32 Read (uint32 ea);
133 void Write (uint32 ea, uint32 dat);
134
135 #endif