Commit | Line | Data |
---|---|---|
196ba1fc PH |
1 | /* i1620_defs.h: IBM 1620 simulator definitions\r |
2 | \r | |
3 | Copyright (c) 2002-2005, Robert M. Supnik\r | |
4 | \r | |
5 | Permission is hereby granted, free of charge, to any person obtaining a\r | |
6 | copy of this software and associated documentation files (the "Software"),\r | |
7 | to deal in the Software without restriction, including without limitation\r | |
8 | the rights to use, copy, modify, merge, publish, distribute, sublicense,\r | |
9 | and/or sell copies of the Software, and to permit persons to whom the\r | |
10 | Software is furnished to do so, subject to the following conditions:\r | |
11 | \r | |
12 | The above copyright notice and this permission notice shall be included in\r | |
13 | all copies or substantial portions of the Software.\r | |
14 | \r | |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r | |
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r | |
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r | |
18 | ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r | |
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r | |
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r | |
21 | \r | |
22 | Except as contained in this notice, the name of Robert M Supnik shall not be\r | |
23 | used in advertising or otherwise to promote the sale, use or other dealings\r | |
24 | in this Software without prior written authorization from Robert M Supnik.\r | |
25 | \r | |
26 | This simulator is based on the 1620 simulator written by Geoff Kuenning.\r | |
27 | I am grateful to Al Kossow, the Computer History Museum, and the IBM Corporate\r | |
28 | Archives for their help in gathering documentation about the IBM 1620.\r | |
29 | \r | |
30 | 18-Oct-02 RMS Fixed bug in ADDR_S macro (found by Hans Pufal)\r | |
31 | */\r | |
32 | \r | |
33 | #ifndef _I1620_DEFS_H_\r | |
34 | #define _I1620_DEFS_H_ 0\r | |
35 | \r | |
36 | #include "sim_defs.h" /* simulator defns */\r | |
37 | \r | |
38 | /* Simulator stop codes */\r | |
39 | \r | |
40 | #define STOP_HALT 1 /* HALT */\r | |
41 | #define STOP_IBKPT 2 /* breakpoint */\r | |
42 | #define STOP_INVINS 3 /* invalid instruction */\r | |
43 | #define STOP_INVDIG 4 /* invalid digit */\r | |
44 | #define STOP_INVCHR 5 /* invalid char */\r | |
45 | #define STOP_INVIND 6 /* invalid indicator */\r | |
46 | #define STOP_INVPDG 7 /* invalid P addr digit */\r | |
47 | #define STOP_INVPAD 8 /* invalid P addr */\r | |
48 | #define STOP_INVPIA 9 /* invalid P indir addr */\r | |
49 | #define STOP_INVQDG 10 /* invalid Q addr digits */\r | |
50 | #define STOP_INVQAD 11 /* invalid Q addr */\r | |
51 | #define STOP_INVQIA 12 /* invalid Q indir addr */\r | |
52 | #define STOP_INVIO 13 /* invalid IO address */\r | |
53 | #define STOP_INVRTN 14 /* invalid return */\r | |
54 | #define STOP_INVFNC 15 /* invalid function */\r | |
55 | #define STOP_INVIAD 16 /* invalid instr addr */\r | |
56 | #define STOP_INVSEL 17 /* invalid select */\r | |
57 | #define STOP_INVIDX 18 /* invalid index instr */\r | |
58 | #define STOP_INVEAD 19 /* invalid even addr */\r | |
59 | #define STOP_INVDCF 20 /* invalid DCF addr */\r | |
60 | #define STOP_INVDRV 21 /* invalid disk drive */\r | |
61 | #define STOP_INVDSC 22 /* invalid disk sector */\r | |
62 | #define STOP_INVDCN 23 /* invalid disk count */\r | |
63 | #define STOP_INVDBA 24 /* invalid disk buf addr */\r | |
64 | #define STOP_DACERR 25 /* disk addr comp err */\r | |
65 | #define STOP_DWCERR 26 /* disk wr check err */\r | |
66 | #define STOP_CYOERR 27 /* cylinder ovflo err */\r | |
67 | #define STOP_WRLERR 28 /* wrong rec lnt err */\r | |
68 | #define STOP_CCT 29 /* runaway CCT */\r | |
69 | #define STOP_FWRAP 30 /* field wrap */\r | |
70 | #define STOP_RWRAP 31 /* record wrap */\r | |
71 | #define STOP_NOCD 32 /* no card in reader */\r | |
72 | #define STOP_OVERFL 33 /* overflow */\r | |
73 | #define STOP_EXPCHK 34 /* exponent error */\r | |
74 | #define STOP_WRADIS 35 /* write addr disabled */\r | |
75 | #define STOP_FPLNT 36 /* invalid fp length */\r | |
76 | #define STOP_FPUNL 37 /* fp lengths unequal */\r | |
77 | #define STOP_FPMF 38 /* no flag on exp */\r | |
78 | #define STOP_FPDVZ 39 /* divide by zero */\r | |
79 | \r | |
80 | /* Memory */\r | |
81 | \r | |
82 | #define MAXMEMSIZE 60000 /* max mem size */\r | |
83 | #define MEMSIZE (cpu_unit.capac) /* act memory size */\r | |
84 | \r | |
85 | /* Processor parameters */\r | |
86 | \r | |
87 | #define INST_LEN 12 /* inst length */\r | |
88 | #define ADDR_LEN 5 /* addr length */\r | |
89 | #define MUL_TABLE 100 /* multiply table */\r | |
90 | #define MUL_TABLE_LEN 200\r | |
91 | #define ADD_TABLE 300 /* add table */\r | |
92 | #define ADD_TABLE_LEN 100\r | |
93 | #define IDX_A 300 /* index A base */\r | |
94 | #define IDX_B 340 /* index B base */\r | |
95 | #define PROD_AREA 80 /* product area */\r | |
96 | #define PROD_AREA_LEN 20 /* product area */\r | |
97 | #define PROD_AREA_END (PROD_AREA + PROD_AREA_LEN)\r | |
98 | \r | |
99 | /* Branch indicator codes */\r | |
100 | \r | |
101 | #define NUM_IND 100 /* number of indicators */\r | |
102 | \r | |
103 | #define IN_SW1 1 /* sense switch 1 */\r | |
104 | #define IN_SW2 2 /* sense switch 2 */\r | |
105 | #define IN_SW3 3 /* sense switch 3 */\r | |
106 | #define IN_SW4 4 /* sense switch 4 */\r | |
107 | #define IN_RDCHK 6 /* read check (I/O error) */\r | |
108 | #define IN_WRCHK 7 /* write check (I/O error) */\r | |
109 | #define IN_LAST 9 /* last card was just read */\r | |
110 | #define IN_HP 11 /* high or positive result */\r | |
111 | #define IN_EZ 12 /* equal or zero result */\r | |
112 | #define IN_HPEZ 13 /* high/positive or equal/zero */\r | |
113 | #define IN_OVF 14 /* overflow */\r | |
114 | #define IN_EXPCHK 15 /* floating exponent check */\r | |
115 | #define IN_MBREVEN 16 /* even parity check */\r | |
116 | #define IN_MBRODD 17 /* odd parity check */\r | |
117 | #define IN_ANYCHK 19 /* any of read, write, even/odd */\r | |
118 | #define IN_PRCHK 25 /* printer check */\r | |
119 | #define IN_IXN 30 /* IX neither */\r | |
120 | #define IN_IXA 31 /* IX A band */\r | |
121 | #define IN_IXB 32 /* IX B band */\r | |
122 | #define IN_PRCH9 33 /* printer chan 9 */\r | |
123 | #define IN_PRCH12 34 /* printer chan 12 */\r | |
124 | #define IN_PRBSY 35 /* printer busy */\r | |
125 | #define IN_DACH 36 /* disk addr/data check */\r | |
126 | #define IN_DWLR 37 /* disk rec length */\r | |
127 | #define IN_DCYO 38 /* disk cyl overflow */\r | |
128 | #define IN_DERR 39 /* disk any error */\r | |
129 | \r | |
130 | /* I/O channel codes */\r | |
131 | \r | |
132 | #define NUM_IO 100 /* number of IO chan */\r | |
133 | \r | |
134 | #define IO_TTY 1 /* console typewriter */\r | |
135 | #define IO_PTP 2 /* paper-tape punch */\r | |
136 | #define IO_PTR 3 /* paper-tape reader */\r | |
137 | #define IO_CDP 4 /* card punch */\r | |
138 | #define IO_CDR 5 /* card reader */\r | |
139 | #define IO_DSK 7 /* disk */\r | |
140 | #define IO_LPT 9 /* line printer */\r | |
141 | #define IO_BTP 32 /* binary ptp */\r | |
142 | #define IO_BTR 33 /* binary ptr */\r | |
143 | \r | |
144 | #define LPT_WIDTH 120 /* line print width */\r | |
145 | #define CCT_LNT 132 /* car ctrl length */\r | |
146 | \r | |
147 | #define CRETIOE(f,c) return ((f)? (c): SCPE_OK)\r | |
148 | \r | |
149 | /* Memory representation: flag + BCD digit per byte */\r | |
150 | \r | |
151 | #define FLAG 0x10\r | |
152 | #define DIGIT 0x0F\r | |
153 | #define REC_MARK 0xA\r | |
154 | #define NUM_BLANK 0xC\r | |
155 | #define GRP_MARK 0xF\r | |
156 | #define BAD_DIGIT(x) ((x) > 9)\r | |
157 | \r | |
158 | /* Instruction format */\r | |
159 | \r | |
160 | #define I_OP 0 /* opcode */\r | |
161 | #define I_P 2 /* P start */\r | |
162 | #define I_PL 6 /* P end */\r | |
163 | #define I_Q 7 /* Q start */\r | |
164 | #define I_QL 11 /* Q end */\r | |
165 | #define I_IO 8 /* IO select */\r | |
166 | #define I_BR 8 /* indicator select */\r | |
167 | #define I_CTL 10 /* control select */\r | |
168 | #define I_SEL 11 /* BS select */\r | |
169 | \r | |
170 | #define ADDR_A(x,a) ((((x) + (a)) >= MEMSIZE)? ((x) + (a) - MEMSIZE): ((x) + (a)))\r | |
171 | #define ADDR_S(x,a) (((x) < (a))? ((x) - (a) + MEMSIZE): ((x) - (a)))\r | |
172 | #define PP(x) x = ADDR_A(x,1)\r | |
173 | #define MM(x) x = ADDR_S(x,1)\r | |
174 | \r | |
175 | /* CPU options, stored in cpu_unit.flags */\r | |
176 | /* Decoding flags must be part of the same definition set */\r | |
177 | \r | |
178 | #define UNIT_SCP ((1 << UNIT_V_UF) - 1) /* mask of SCP flags */\r | |
179 | #define IF_MII (1 << (UNIT_V_UF + 0)) /* model 2 */\r | |
180 | #define IF_DIV (1 << (UNIT_V_UF + 1)) /* automatic divide */\r | |
181 | #define IF_IA (1 << (UNIT_V_UF + 2)) /* indirect addressing */\r | |
182 | #define IF_EDT (1 << (UNIT_V_UF + 3)) /* edit */\r | |
183 | #define IF_FP (1 << (UNIT_V_UF + 4)) /* floating point */\r | |
184 | #define IF_BIN (1 << (UNIT_V_UF + 5)) /* binary */\r | |
185 | #define IF_IDX (1 << (UNIT_V_UF + 6)) /* indexing */\r | |
186 | #define IF_VPA (1 << (UNIT_V_UF + 7)) /* valid P addr */\r | |
187 | #define IF_VQA (1 << (UNIT_V_UF + 8)) /* valid Q addr */\r | |
188 | #define IF_4QA (1 << (UNIT_V_UF + 9)) /* 4 char Q addr */\r | |
189 | #define IF_NQX (1 << (UNIT_V_UF + 10)) /* no Q indexing */\r | |
190 | #define IF_IMM (1 << (UNIT_V_UF + 11)) /* immediate */\r | |
191 | #define UNIT_BCD (1 << (UNIT_V_UF + 12)) /* BCD coded */\r | |
192 | #define UNIT_MSIZE (1 << (UNIT_V_UF + 13)) /* fake flag */\r | |
193 | #define ALLOPT (IF_DIV + IF_IA + IF_EDT + IF_FP + IF_BIN + IF_IDX)\r | |
194 | #define MI_OPT (IF_DIV + IF_IA + IF_EDT + IF_FP)\r | |
195 | #define MI_STD (IF_DIV + IF_IA + IF_EDT)\r | |
196 | #define MII_OPT (ALLOPT)\r | |
197 | #define MII_STD (IF_DIV + IF_IA + IF_EDT + IF_BIN + IF_IDX)\r | |
198 | \r | |
199 | /* Add status codes */\r | |
200 | \r | |
201 | #define ADD_NOCRY 0 /* no carry out */\r | |
202 | #define ADD_CARRY 1 /* carry out */\r | |
203 | #define ADD_SIGNC 2 /* sign change */\r | |
204 | \r | |
205 | /* Opcodes */\r | |
206 | \r | |
207 | enum opcodes {\r | |
208 | OP_FADD = 1, OP_FSUB, OP_FMUL, /* 00 - 09 */\r | |
209 | OP_FSL = 5, OP_TFL, OP_BTFL, OP_FSR, OP_FDIV,\r | |
210 | OP_BTAM = 10, OP_AM, OP_SM, OP_MM, OP_CM, /* 10 - 19 */\r | |
211 | OP_TDM, OP_TFM, OP_BTM, OP_LDM, OP_DM,\r | |
212 | OP_BTA = 20, OP_A, OP_S, OP_M, OP_C, /* 20 - 29 */\r | |
213 | OP_TD, OP_TF, OP_BT, OP_LD, OP_D,\r | |
214 | OP_TRNM = 30, OP_TR, OP_SF, OP_CF, OP_K, /* 30 - 39 */\r | |
215 | OP_DN, OP_RN, OP_RA, OP_WN, OP_WA,\r | |
216 | OP_NOP = 41, OP_BB, OP_BD, OP_BNF, /* 40 - 49 */\r | |
217 | OP_BNR, OP_BI, OP_BNI, OP_H, OP_B,\r | |
218 | OP_BNG = 55,\r | |
219 | OP_BS = 60, OP_BX, OP_BXM, OP_BCX, OP_BCXM, /* 60 - 69 */\r | |
220 | OP_BLX, OP_BLXM, OP_BSX,\r | |
221 | OP_MA = 70, OP_MF, OP_TNS, OP_TNF, /* 70 - 79 */\r | |
222 | /* 80 - 89 */\r | |
223 | OP_BBT = 90, OP_BMK, OP_ORF, OP_ANDF, OP_CPLF, /* 90 - 99 */\r | |
224 | OP_EORF, OP_OTD, OP_DTO };\r | |
225 | \r | |
226 | #endif\r |