GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
msl-states.c
Go to the documentation of this file.
1#include <stdint.h>
2#include "bit.h"
3#include "msl-timings.h"
4#include "signals.h"
5
6#define MSL_COMMANDS_INCLUDED_BY_MSL_STATES
7#include "msl-commands.c"
8#undef MSL_COMMANDS_INCLUDED_BY_MSL_STATES
9
10#ifndef MSL_STATES_INCLUDED_BY_MSL_TIMINGS
11# error This file should be include by msl-timings.c and not compiled directly
12#endif
13
14/* The states below transcribe the micro-sequencer flow-chart foldouts
15 * (drawing 14023130, CPU[7] = Volume 7 schematics). docs/flowchart-sheets.md
16 * maps each sheet -> the state(s) here and records the per-state fidelity audit
17 * (which states are faithful per-clock transcriptions vs. functionally-correct
18 * hybrids that call the alu_* helpers). Sheet citations are noted on each chart. */
19
20/* Common Conditions */
21/* ----------------- */
22
23static uint8_t not_RO00(struct ge *ge) { return !BIT(ge->rRO, 0); }
24static uint8_t not_RO01(struct ge *ge) { return !BIT(ge->rRO, 1); }
25static uint8_t not_RO02(struct ge *ge) { return !BIT(ge->rRO, 2); }
26static uint8_t not_RO03(struct ge *ge) { return !BIT(ge->rRO, 3); }
27static uint8_t not_RO04(struct ge *ge) { return !BIT(ge->rRO, 4); }
28static uint8_t not_RO05(struct ge *ge) { return !BIT(ge->rRO, 5); }
29static uint8_t not_RO06(struct ge *ge) { return !BIT(ge->rRO, 6); }
30static uint8_t not_RO07(struct ge *ge) { return !BIT(ge->rRO, 7); }
31
32/* Address modify flag (bit 15 of the operand address = L2 bit 7 once the
33 * addr-hi byte has been read into L2). An absolute address exits operand
34 * fetch to beta; a modified one detours through the indexing micro-cycle.
35 * (SIG(L207)/SIG(not_L207) are defined later in this file for the TPER/CPER
36 * path; this mirrors them but is visible to the alpha-phase states below.) */
37static uint8_t addr_absolute(struct ge *ge) { return !BIT(ge->rL2, 7); }
38
39/* Change-register modifier bits of the operand field (L2 bits 4-6 = address
40 * bits 12-14). Gate the NO-knot forcings CO91/CO92/CO93 that build the
41 * change-register byte address in the indexing micro-cycle (CPU[7] p64,
42 * equations EG63A0/EG62A0/EG61A0). Also used by the TPER/CPER cluster. */
43SIG(L204) { return BIT(ge->rL2, 4); }
44SIG(L205) { return BIT(ge->rL2, 5); }
45SIG(L206) { return BIT(ge->rL2, 6); }
46
47/* Register-number bits of the register-instruction format (L1 bits 4-6),
48 * gating the change-register address build CO91/CO92/CO93 in the LA and
49 * LR-family beta sheets (cp07 fo.36/37, equations EG60A0/EG59A0/EG58A0). */
50static uint8_t LI04(struct ge *ge) { return BIT(ge->rL1, 4); }
51static uint8_t LI05(struct ge *ge) { return BIT(ge->rL1, 5); }
52static uint8_t LI06(struct ge *ge) { return BIT(ge->rL1, 6); }
53
54/* Initialitiation */
55/* --------------- */
56
57// to state E2+E3 if !AINI
58// C8 if AINI
59
60static uint8_t AINI(struct ge *ge) { return ge->AINI; }
61static uint8_t not_AINI(struct ge *ge) { return !AINI(ge); }
62
63
64static uint8_t state_80_TO30_CO96(struct ge *ge) {
65 return (ge->ALOI && !FUL2(ge)) || (!ge->ALOI && !FUL3(ge));
66}
67
68static uint8_t state_80_TO30_CO97(struct ge *ge) {
69 return ge->ALOI && FUL2(ge);
70}
71
72static const struct msl_timing_chart state_80[] = {
73 { TO30, CI19, 0, DI28A0 },
74 { TO30, CO96, state_80_TO30_CO96 },
75 { TO30, CO97, state_80_TO30_CO97 },
76 { TO40, CO00, 0 },
77 { TO40, CO02, 0 },
78 { TO50, CI32, 0, DI28A0 },
79 { TO70, CI62, 0 },
80 { TO70, CI67, 0, DI28B0 },
81 { TI05, CI05, 0, DI28B0 },
82 { TI05, CI08, 0 },
83 { TI06, CI76, 0 },
84 { TI06, CI80, 0 },
85 { TI06, CI81, 0 },
86 { TI06, CI82, 0 },
87 { TI06, CU01, not_AINI },
88 { TI06, CU03, AINI },
89 { TI06, CU05, not_AINI },
90 { TI06, CU06, 0 },
91 { END_OF_STATUS, 0, 0 }
92};
93
94// Alpha phase
95
96// (to state F0 if RINT & !FA06
97// E0 if !RINT | FA06)
98
99static uint8_t state_E2_E3_TO80_CI89(struct ge *ge) {
100 /* (deltaRO = HLT + ASIN(ATOC+!ADIR))
101 *
102 * Both terms now. ASIN is the operator panel's STEP-BY-STEP switch, which
103 * stops the machine at each instruction through this very command -- the
104 * one HLT uses -- which is why the stop lands with the program addresser
105 * still on the OP code just read (CPU[4] §5.1 b). ATOC = STOC overrides a
106 * program inhibit set by INS (ADIR). The maintenance PAPA switch is a
107 * different circuit entirely and does not come through here. */
108 return ge->rRO == HLT_OPCODE ||
109 (ge->ASIN && (ge->console_switches.STOC || !ge->ADIR));
110}
111
112static uint8_t state_E2_E3_TI06_CI82(struct ge *ge) {
113 return ge->rRO == PER_OPCODE;
114}
115
116static uint8_t state_E2_E3_TI06_CU04(struct ge *ge) {
117 return ge->RINT && !BIT(ge->ffFA, 6);
118}
119
120static const struct msl_timing_chart state_E2_E3[] = {
121 { TO10, CO10, 0 },
122 { TO10, CO41, 0, DI12A0 },
123 { TO25, CO30, 0, DI12A0 },
124 { TO40, CO02, 0, DI18B0 },
125 { TO70, CI67, 0, DI12A0 },
126 { TO70, CI62, 0, DI12A0 },
127 { TO80, CI89, state_E2_E3_TO80_CI89 },
128 { TI05, CI08, 0 },
129 { TI06, CI80, 0 },
130 /* Reset FI01. Present in the per-clock timing table (14024137 fo.10/11,
131 * CPU[7] p61: "TI06 CI81 CI81A0 = EC73A0") but was missing here. FI01 is set
132 * only by forcing (state 08) / the b1 peripheral path, so the instruction
133 * fetch clearing it is a no-op for normal CPU flow (verified: deck + tests
134 * stay green). EC73A0 isn't transcribed; like the sibling CI80/CI83 resets
135 * (table cond DI18B0 = the in-state decode) it is treated as unconditional. */
136 { TI06, CI81, 0 },
137 { TI06, CI82, state_E2_E3_TI06_CI82 },
138 { TI06, CI83, 0 },
139 { TI06, CU04, state_E2_E3_TI06_CU04 },
140 { TI06, CU10, 0 },
141 { TI06, CU11, 0, DI18A0 },
142 { END_OF_STATUS, 0, 0 }
143};
144
145// to state E4 if FO06 | FO07
146// 64+65 if !(FO06 | FO07)
147
148static uint8_t state_E0_TI06_CU17(struct ge *ge) {
149 return !(BIT(ge->rFO, 6) || BIT(ge->rFO, 7));
150}
151
152static const struct msl_timing_chart state_E0[] = {
153 { TO10, CO12, 0, DI17A0 },
154 { TO10, CO41, 0, DI12A0 },
155 { TO25, CO30, 0, DI12A0 },
156 { TO40, CO00, 0, DI17A0 },
157 { TO70, CI67, 0, DI12A0 },
158 { TO70, CI62, 0, DI12A0 },
159 { TO80, CI39, 0 },
160 { TI05, CI05, 0, DI17A0 },
161 { TI06, CU02, 0 },
162 { TI06, CU17, state_E0_TI06_CU17 },
163 { END_OF_STATUS, 0, 0 }
164};
165
166// SS (Storage-to-Storage) data ops: opcode list from opcodes.h.
167// These are 6-byte instructions (opcode, LL, A1hi, A1lo, A2hi, A2lo).
168// Operands are loaded by the E4->E6->E5->E7 micro-loop:
169// E4 -> E6 (loads V1 from A1), E5 -> E7 (loads V2 from A2); a modified
170// address detours through the indexing micro-cycle ED|EC -> EF|EE. E7 then
171// exits to beta (64|65 family) via its documented CU rows, where the op
172// executes (EXEC_SS at TO65, like the other EXEC_* hybrids).
173// V1 = destination address, V2 = source address, L1 = length byte.
174static uint8_t is_ss_data_op(struct ge *ge) {
175 switch (ge->rFO) {
176 case MVC_OPCODE:
177 case NC_OPCODE:
178 case CMC_OPCODE:
179 case OC_OPCODE:
180 case XC_OPCODE:
181 case UPK_OPCODE:
182 case PK_OPCODE:
183 case TR_OPCODE:
184 case EDT_OPCODE:
185 case MVP_OPCODE:
186 case CMP_OPCODE:
187 case AP_OPCODE:
188 case SP_OPCODE:
189 case MP_OPCODE:
190 case DP_OPCODE:
191 case PKS_OPCODE:
192 case UPKS_OPCODE:
193 case AB_OPCODE:
194 case SB_OPCODE:
195 case AD_OPCODE:
196 case SD_OPCODE:
197 case MVQ_OPCODE:
198 case CMQ_OPCODE:
199 case SR_OPCODE:
200 case SL_OPCODE:
201 return 1;
202 default:
203 return 0;
204 }
205}
206
207// to state E6
208
209/* E4 reads the FIRST operand's high byte (A1hi), exactly as E5 reads A2hi; CI60
210 * (ni4 = top quartet = modifier+bit15) fires on /R007 (= not_RO07), matching the
211 * E5 box (CPU[7] flow chart 14023130). The original `return 0` stub never loaded
212 * it, so for absolute addresses the SS destination lost its high quartet and
213 * writes fell into segment 0; restoring the /R007 gating fixes that. (For the
214 * modified case the hardware zeroes V4 and indexes in ED|EC|EF|EE — transcribed
215 * in reference_operand_fetch_flowchart, to be implemented cycle-accurately.) */
216static uint8_t state_E4_TO70_CI60(struct ge *ge) { return not_RO07(ge); }
217static uint8_t RO07(struct ge *ge) { return BIT(ge->rRO, 7); }
218
219static const struct msl_timing_chart state_E4[] = {
220 { TO10, CO10, 0, DI60A0 },
221 { TO10, CO41, 0, DI60A0 },
222 { TO25, CO30, 0, DI12A0 },
223 { TO40, CO00, 0, DI60A0 },
224 { TO70, CI67, 0, DI12A0 },
225 { TO70, CI62, 0, DI12A0 },
226 { TO70, CI65, 0, DI19A0 },
227 { TO70, CI60, state_E4_TO70_CI60 },
228 { TO70, NI4_ZERO, RO07 }, /* 0->V_4 [R007]: strip modifier+flag */
229 { TI05, CI02, 0 },
230 { TI06, CI06, 0 },
231 { TI06, CU01, 0, DI60A0 },
232 { END_OF_STATUS, 0, 0 }
233};
234
235// to state E5 if !L207 & (FO07 & FO06)
236// ED if L207 (modified-address indexing cycle; the unconditional
237// CU00 leaves bit 0 SET = first operand <SA00>)
238// 64+65 if !L207 & (!FO07 | !FO06)
239
240/* CI38 "set AVER auto" in E6/E7: gate DE51A0 = DO011 & DI201 (cp06 ch.261
241 * gate 8, read on the sheet: DE51A = NAND(DO011, DI201)) — fires only for the
242 * jump-class function codes (DO011 = FO06 & !FO03 & !FO07). Previously E6
243 * returned 0 and E7 returned 1, both guesses ("DO01?"). */
244static uint8_t state_E6_TO80_CI38(struct ge *ge) { return DO011(ge); }
245
246static uint8_t state_E6_TI06_CU17(struct ge *ge) {
247 return (!BIT(ge->rL2, 7) &&
248 (!BIT(ge->rFO, 7) || !BIT(ge->rFO, 6)));
249}
250
251static const struct msl_timing_chart state_E6[] = {
252 { TO10, CO10, 0, DI60A0 },
253 { TO10, CO41, 0, DI60A0 },
254 { TO25, CO30, 0, DI12A0 },
255 { TO30, CI12, 0 },
256 { TO40, CO00, 0, DI60A0 },
257 { TO70, CI67, 0, DI12A0 },
258 { TO70, CI62, 0, DI12A0 },
259 { TO80, CI38, state_E6_TO80_CI38 },
260 { TI05, CI01, 0 },
261 { TI05, CI02, 0 },
262 { TI06, CU00, 0, DI20A0 },
263 /* EC56A0 = DI201 & L207: enter the indexing micro-cycle on a modified
264 * address (timing table CPU[7] p63 prints the same gate for E7). */
265 { TI06, CU03, 0, EC56A0 },
266
267 /* in the manual this is CU10, but it maybe a mistake.. there's no way to reach
268 * the alpha states if we don't reset this bit 1 instead of bit 0 */
269 { TI06, CU11, 0 },
270
271 { TI06, CU17, state_E6_TI06_CU17 },
272 { END_OF_STATUS, 0, 0 }
273};
274
275// to state E7
276
277static const struct msl_timing_chart state_E5[] = {
278 { TO10, CO10, 0, DI60A0 },
279 { TO10, CO41, 0, DI60A0 },
280 { TO25, CO30, 0, DI12A0 },
281 { TO40, CO00, 0, DI60A0 },
282 { TO70, CI67, 0, DI12A0 },
283 { TO70, CI62, 0, DI12A0 },
284 { TO70, CI65, 0, DI19A0 },
285 { TO70, CI60, not_RO07 }, /* ni4 [/R007]: top quartet from RO only
286 * for absolute (CPU[7] E5 box) */
287 { TO70, NI4_ZERO, RO07 }, /* 0->V_4 [R007]: strip modifier+flag */
288 { TI05, CI02, 0 },
289 { TI06, CI06, 0 },
290 { TI06, CU01, 0, DI60A0 },
291 { END_OF_STATUS, 0, 0 }
292};
293
294// to state 64+65 if !L207 (beta: the SS op executes there)
295// ED+EC if L207 (the CU10 = DI64A0 reset of bit 0 lands on EC =
296// second operand, the <SA00> diamond cleared)
297
298static uint8_t state_E7_TO80_CI38(struct ge *ge) { return DO011(ge); /* DE51A0, see E6 */ }
299
300/* Timing table CPU[7] p63 (state 1110 0111, DA-FROM E5), verified row-by-row:
301 * TO10 CO10 = CB19A0 (DI60A0) PO->NO
302 * TO10 CO41 = CB14A0 (DI60A0) count from 00
303 * TO25 CO30 = CB07A0 (DI12A0) MEM->RO
304 * TO30 CI12 = DI20A0 V2->NO
305 * TO40 CO00 = CB00A0 (DI60A0) NI->PO
306 * TO50 (hardware) NO->BO
307 * TO70 CI67 = CD14A0 (DI12A0) RO1->NI1
308 * TO70 CI62 = CD14A0 (DI12A0) RO2->NI2
309 * TO80 CI38 = DE51A0 {DO01} set AVER auto
310 * TI05 CI02 = DI60A0 NI->V2
311 * TI06 CU00 = CM00A0 (DI20A0) Set S000
312 * TI06 CU03 = CM05A0 (EC56A0) Set S003 (modified address)
313 * TI06 CU10 = DI64A0 Reset S000 (E7-only: operand 2 -> EC)
314 * TI06 CU17 = EC57A0 {/L207} Reset S007 (absolute -> beta)
315 * Exit box: 64+65 (0110 0100) {/L207} | ED+EC (1110 1100) {L207}.
316 * Reaching those exact exit codes needs a bit-1 reset the printed rows lack;
317 * a CU11 is added below — the same manual CU10/CU11 ambiguity already noted
318 * in state_E6. The exit-box state codes are unambiguous. */
319static const struct msl_timing_chart state_E7[] = {
320 { TO10, CO10, 0, DI60A0 },
321 { TO10, CO41, 0, DI60A0 },
322 { TO25, CO30, 0, DI12A0 },
323 { TO30, CI12, 0, DI20A0 },
324 { TO40, CO00, 0, DI60A0 },
325 { TO70, CI67, 0, DI12A0 },
326 { TO70, CI62, 0, DI12A0 },
327 { TO80, CI38, state_E7_TO80_CI38 },
328 { TI05, CI02, 0, DI60A0 },
329 { TI06, CU00, 0, DI20A0 },
330 { TI06, CU03, 0, EC56A0 },
331 { TI06, CU10, 0, DI64A0 },
332 { TI06, CU11, 0, DI64A0 },
333 { TI06, CU17, addr_absolute }, /* CU17A0 = EC57A0 {/L207} */
334 { END_OF_STATUS, 0, 0 }
335};
336
337/* Modified-Address Indexing Micro-Cycle */
338/* ------------------------------------- */
339
340/* Entered from E6 (operand 1 -> ED, SA bit 0 set) or E7 (operand 2 -> EC,
341 * SA bit 0 cleared by CU10 = DI64A0); SA bit 0 IS the flow chart's <SA00>
342 * first-vs-second operand diamond. Per-clock transcription of the timing
343 * tables CPU[7] p64 ("FASE ALFA ED-EC / EF-EE", dwg 14024137₀, fo.15-16):
344 *
345 * ED|EC — CO18 + CO97..CO90 force the NO knot to the change-register LOW
346 * byte address 1111 nnn 1 = 241+2N (N = modifier, L2 bits 4-6 via
347 * the {L206}/{L205}/{L204} gates; CO90's DI65A0 gate sets the odd
348 * byte only in this state); MEM->RO reads it; V2->NO / NO->BO put
349 * the displacement on the UA's other input; CO49 resets the carry
350 * FFs; CI69 latches UA = BO.low + RO into NI21; CI02 stores NI
351 * (V2 high byte unchanged through the counting network) to V2;
352 * CU01 -> EF|EE.
353 * EF|EE — same address build WITHOUT CO90 (= 240+2N, the HIGH byte);
354 * CI68 latches UA = BO.high + RO + carry into NI43; CI02 stores
355 * the resolved EA to V2; CI01 (DI67A0 {SA00}) copies it to V1 for
356 * the first operand. Routing: CU01/CU11 (net Reset S001) + CU13
357 * always; CU17 = DE52A0 {/FO07+/FO06+/SA00} exits to beta except
358 * for the first operand of a two-address op, which goes to E5 to
359 * fetch operand 2. Exit box: 64+65 {/(SA00·FO07·FO06)} |
360 * E5 {SA00·FO07·FO06}.
361 */
362static uint8_t state_EF_EE_TI06_CU17(struct ge *ge) {
363 return !(BIT(ge->rFO, 7) && BIT(ge->rFO, 6) && BIT(ge->rSA, 0));
364}
365
366static const struct msl_timing_chart state_ED_EC[] = {
367 { TO10, CO18, 0, DI13A0 }, /* forcing in NO21 */
368 { TO10, CO97, 0, DI13A0 }, /* 1->NO07 */
369 { TO10, CO96, 0, DI13A0 }, /* 1->NO06 */
370 { TO10, CO95, 0, DI13A0 }, /* 1->NO05 */
371 { TO10, CO94, 0, DI13A0 }, /* 1->NO04 */
372 { TO10, CO93, L206, DI13A0 }, /* EG61A0 {L206}: N2->NO03 */
373 { TO10, CO92, L205, DI13A0 }, /* EG62A0 {L205}: N1->NO02 */
374 { TO10, CO91, L204, DI13A0 }, /* EG63A0 {L204}: N0->NO01 */
375 { TO10, CO90, 0, DI65A0 }, /* 1->NO00: low (odd) cr byte */
376 { TO25, CO30, 0, DI13A0 }, /* MEM->RO */
377 { TO30, CI12, 0, DI13A0 }, /* V2->NO */
378 { TO65, CO49, 0, DI65A0 }, /* reset URPE/URPU (carry) */
379 { TO70, CI69, 0, DI65A0 }, /* UA->NI21: BO.low + RO */
380 { TI05, CI02, 0, DI13A0 }, /* NI->V2 */
381 { TI06, CU01, 0, DI13A0 }, /* Set S001 -> EF|EE */
382 { END_OF_STATUS, 0, 0 }
383};
384
385static const struct msl_timing_chart state_EF_EE[] = {
386 { TO10, CO18, 0, DI13A0 }, /* forcing in NO21 */
387 { TO10, CO97, 0, DI13A0 }, /* 1->NO07 */
388 { TO10, CO96, 0, DI13A0 }, /* 1->NO06 */
389 { TO10, CO95, 0, DI13A0 }, /* 1->NO05 */
390 { TO10, CO94, 0, DI13A0 }, /* 1->NO04 */
391 { TO10, CO93, L206, DI13A0 }, /* EG61A0 {L206}: N2->NO03 */
392 { TO10, CO92, L205, DI13A0 }, /* EG62A0 {L205}: N1->NO02 */
393 { TO10, CO91, L204, DI13A0 }, /* EG63A0 {L204}: N0->NO01 */
394 { TO25, CO30, 0, DI13A0 }, /* MEM->RO (high/even cr byte) */
395 { TO30, CI12, 0, DI13A0 }, /* V2->NO */
396 { TO70, CI68, 0, DI66A0 }, /* UA->NI43: BO.high + RO + carry */
397 { TI05, CI02, 0, DI13A0 }, /* NI->V2: resolved EA */
398 { TI05, CI01, 0, DI67A0 }, /* NI->V1 {SA00}: first operand only */
399 { TI06, CU01, 0, DI13A0 }, /* Set S001 ... */
400 { TI06, CU11, 0, DI66A0 }, /* ... net Reset S001 in EF|EE */
401 { TI06, CU13, 0, DI66A0 }, /* Reset S003 */
402 { TI06, CU17, state_EF_EE_TI06_CU17 }, /* DE52A0 {/FO07+/FO06+/SA00} */
403 { END_OF_STATUS, 0, 0 }
404};
405
406/* Interruption + LPSR */
407/* ------------------- */
408
409/* Interruption + LPSR chain, per-clock (cp07 timing charts fo.22-31, dwg
410 * 14024137, read from source at 600dpi):
411 *
412 * E2/E3 --INTE--> F0 -> D2 -> D3 -> D0 -> D1 -> C2 -> C3 -> C0 -> C1 -> E2/E3
413 * LPSR (beta 64|65, fo.27) ------------------------^ (C2 header: "DA-FROM 64+65 D1")
414 *
415 * F0 forces 0x0300 into V1 (CI19 + C091/C090 -> NO43, latched into BO at the
416 * TO50 relatch, stored by CI01). The D-states WRITE the old PSR at V1++:
417 * D2 = status byte from the FA-gated forcings via NO43 (FA06->b0, FA05->b4,
418 * FA04->b5), D3 = zero (its forcing rows have no mode command, and the NO
419 * selection pulse has decayed by TO50 -> NO_UNDRIVEN), D0/D1 = PO high/low
420 * (CI10 PO->NO at TO30, CI32/CI33 at TO50). The C-states READ the new PSR at
421 * V1++ (0x0304 onward for the interrupt path; the LPSR operand address for
422 * LPSR): C2 = status byte -> FI04/05/06 (set, then conditional reset on the
423 * R0 bits — reset listed after set, as the hardware resolves it), C3 = skip
424 * byte, C0/C1 = PO high/low assembled through NI (RO halves + the BO
425 * passthrough of the counting network, CI00s at TI05).
426 *
427 * TI06 CU rows are ordered sets-before-resets so gemu's sequential dispatch
428 * preserves the hardware "reset prevails" rule; the printed row order on the
429 * sheets is data-equivalent. All exits are unconditional per the sheets. */
430
431static uint8_t FA04(struct ge *ge) { return BIT(ge->ffFA, 4); }
432static uint8_t FA05(struct ge *ge) { return BIT(ge->ffFA, 5); }
433static uint8_t FA06(struct ge *ge) { return BIT(ge->ffFA, 6); }
434
435static const struct msl_timing_chart state_F0[] = { /* fo.22 */
436 { TO30, CI19, 0 }, /* forcing in NO43 */
437 { TO30, CO91, 0 }, /* 1 -> NO09 */
438 { TO30, CO90, 0 }, /* 1 -> NO08: NO = 0x0300 */
439 { TO50, NO_UNDRIVEN, 0 }, /* selection decayed: BO relatch reads
440 * the pure forced 0x0300 */
441 { TI05, CI01, 0 }, /* NI -> V1 (save address) */
442 { TI06, INT_ACK, 0 }, /* gemu request handshake (see command) */
443 { TI06, CU01, 0 }, /* Set S001 */
444 { TI06, CU15, 0 }, /* Reset S005 -> D2 */
445 { END_OF_STATUS, 0, 0 },
446};
447
448static const struct msl_timing_chart state_D2[] = { /* fo.23 */
449 { TO10, CO11, 0 }, /* V1 -> NO (address latch at TO20) */
450 { TO10, CO41, 0 }, /* count from 00 */
451 { TO25, CO31, 0 }, /* RO -> MEM (fires at TO65 on rRO) */
452 { TO30, CI19, 0 }, /* forcing in NO43 */
453 { TO30, CO90, FA06 }, /* status bit 0 */
454 { TO30, CO94, FA05 }, /* status bit 4 */
455 { TO30, CO95, FA04 }, /* status bit 5 */
456 { TO40, CO01, 0 }, /* NI -> V1 : V1+1 */
457 { TO50, NO_UNDRIVEN, 0 }, /* selection decayed by TO50 */
458 { TO50, CI32, 0 }, /* NO43 -> RO: the status byte */
459 { TI06, CU00, 0 }, /* -> D3 */
460 { END_OF_STATUS, 0, 0 },
461};
462
463static const struct msl_timing_chart state_D3[] = { /* fo.24 */
464 { TO10, CO11, 0 },
465 { TO10, CO41, 0 },
466 { TO25, CO31, 0 },
467 { TO30, CO90, FA06 }, /* forcings fire but no mode command: */
468 { TO30, CO94, FA05 }, /* they reach nothing (cf. D1, where */
469 { TO30, CO95, FA04 }, /* they must not corrupt PO-low) */
470 { TO40, CO01, 0 },
471 { TO50, NO_UNDRIVEN, 0 }, /* selection pulse decayed by TO50 */
472 { TO50, CI33, 0 }, /* NO21 -> RO: zero byte */
473 { TI06, CU00, 0 }, /* sets first... */
474 { TI06, CU01, 0 },
475 { TI06, CU10, 0 }, /* ...resets prevail -> D0 */
476 { TI06, CU11, 0 },
477 { END_OF_STATUS, 0, 0 },
478};
479
480static const struct msl_timing_chart state_D0[] = { /* fo.25 */
481 { TO10, CO11, 0 },
482 { TO10, CO41, 0 },
483 { TO25, CO31, 0 },
484 { TO30, CO90, FA06 }, /* inert: no mode command */
485 { TO30, CO94, FA05 },
486 { TO30, CO95, FA04 },
487 { TO30, CI10, 0 }, /* PO -> NO */
488 { TO40, CO01, 0 },
489 { TO50, CI32, 0 }, /* NO43 -> RO: PO high */
490 { TI06, CU00, 0 }, /* -> D1 */
491 { END_OF_STATUS, 0, 0 },
492};
493
494static const struct msl_timing_chart state_D1[] = { /* fo.26 */
495 { TO10, CO11, 0 },
496 { TO10, CO41, 0 },
497 { TO25, CO31, 0 },
498 { TO30, CO90, FA06 }, /* inert */
499 { TO30, CO94, FA05 },
500 { TO30, CO95, FA04 },
501 { TO30, CI10, 0 },
502 { TO40, CO01, 0 },
503 { TO50, CI33, 0 }, /* NO21 -> RO: PO low */
504 { TI06, CU00, 0 }, /* sets first */
505 { TI06, CU01, 0 },
506 { TI06, CU10, 0 },
507 { TI06, CU14, 0 }, /* -> C2 */
508 { END_OF_STATUS, 0, 0 },
509};
510
511static const struct msl_timing_chart state_C2[] = { /* fo.28 */
512 { TO10, CO11, 0 },
513 { TO10, CO41, 0 },
514 { TO25, CO30, 0 }, /* MEM -> RO: new status byte */
515 { TO30, CI19, 0 }, /* forcing in NO43 (as printed; harmless) */
516 { TO30, CO90, FA06 },
517 { TO30, CO94, FA05 },
518 { TO30, CO95, FA04 },
519 { TO40, CO01, 0 },
520 { TO70, CI60, 0 }, /* RO2 -> NI4 */
521 { TO70, CI65, 0 }, /* RO1 -> NI3 */
522 { TI06, CI74, 0 }, /* set FI04... */
523 { TI06, CI75, 0 }, /* set FI05... */
524 { TI06, CI76, 0 }, /* set FI06... */
525 { TI06, CI84, not_RO05 }, /* ...reset FI04 {/R005} */
526 { TI06, CI85, not_RO04 }, /* ...reset FI05 {/R004} */
527 { TI06, CI86, not_RO00 }, /* ...reset FI06 {/R000} */
528 { TI06, CU00, 0 }, /* -> C3 */
529 { END_OF_STATUS, 0, 0 },
530};
531
532static const struct msl_timing_chart state_C3[] = { /* fo.29 */
533 { TO10, CO11, 0 },
534 { TO10, CO41, 0 },
535 { TO25, CO30, 0 },
536 { TO30, CO90, FA06 }, /* inert */
537 { TO30, CO94, FA05 },
538 { TO30, CO95, FA04 },
539 { TO40, CO01, 0 },
540 { TO70, CI62, 0 }, /* RO2 -> NI2 */
541 { TO70, CI67, 0 }, /* RO1 -> NI1 */
542 { TI06, CU00, 0 }, /* sets first */
543 { TI06, CU01, 0 },
544 { TI06, CU10, 0 },
545 { TI06, CU11, 0 }, /* -> C0 */
546 { END_OF_STATUS, 0, 0 },
547};
548
549static const struct msl_timing_chart state_C0[] = { /* fo.30 */
550 { TO10, CO11, 0 },
551 { TO10, CO41, 0 },
552 { TO25, CO30, 0 }, /* MEM -> RO: new PO high */
553 { TO30, CO90, FA06 }, /* inert */
554 { TO30, CO94, FA05 },
555 { TO30, CO95, FA04 },
556 { TO30, CI10, 0 }, /* PO -> NO: low half passthrough */
557 { TO40, CO01, 0 },
558 { TO70, CI60, 0 }, /* RO2 -> NI4 */
559 { TO70, CI65, 0 }, /* RO1 -> NI3 */
560 { TI05, CI00s, 0 }, /* NI -> PO */
561 { TI06, CU00, 0 }, /* -> C1 */
562 { END_OF_STATUS, 0, 0 },
563};
564
565static const struct msl_timing_chart state_C1[] = { /* fo.31 */
566 { TO10, CO11, 0 },
567 { TO10, CO41, 0 },
568 { TO25, CO30, 0 }, /* MEM -> RO: new PO low */
569 { TO30, CO90, FA06 }, /* inert */
570 { TO30, CO94, FA05 },
571 { TO30, CO95, FA04 },
572 { TO30, CI10, 0 }, /* PO -> NO: high half passthrough */
573 { TO40, CO01, 0 },
574 { TO70, CI62, 0 }, /* RO2 -> NI2 */
575 { TO70, CI67, 0 }, /* RO1 -> NI1 */
576 { TI05, CI00s, 0 }, /* NI -> PO */
577 { TI06, CU00, 0 }, /* sets first */
578 { TI06, CU01, 0 },
579 { TI06, CU05, 0 },
580 { TI06, CU10, 0 },
581 { TI06, CU14, 0 }, /* -> E2/E3 */
582 { END_OF_STATUS, 0, 0 },
583};
584
585/* Beta Phase */
586/* ---------- */
587
588static uint8_t jc_js1_js2_jie(struct ge *ge) {
589 return ((ge->rFO == JC_OPCODE) ||
590 (ge->rFO == JU_OPCODE) ||
591 (ge->rFO == JCC_OPCODE) ||
592 (ge->rFO == JRT_OPCODE) ||
593 (ge->rFO == JS1_OPCODE && (ge->rL1 & 0xFF) ==JS1_2NDCHAR) ||
594 (ge->rFO == JS2_OPCODE && (ge->rL1 & 0xFF) ==JS2_2NDCHAR) ||
595 (ge->rFO == JIE_OPCODE && (ge->rL1 & 0xFF) ==JIE_2NDCHAR));
596}
597
598static uint8_t lon_loll(struct ge *ge) {
599 /* The 2nd char is an 8-bit field; mask L1 to its low byte (in real execution
600 * L1's high byte carries leftover bits, unlike the console-forced case). */
601 return ((ge->rFO == LON_OPCODE && (ge->rL1 & 0xFF) == LON_2NDCHAR) ||
602 (ge->rFO == LOLL_OPCODE && (ge->rL1 & 0xFF) == LOLL_OPCODE));
603}
604
605static uint8_t ins(struct ge *ge) {
606 return ge->rFO == INS_OPCODE && (ge->rL1 & 0xFF) ==INS_2NDCHAR;
607}
608
609static uint8_t jie(struct ge *ge) {
610 return ge->rFO == JIE_OPCODE && (ge->rL1 & 0xFF) ==JIE_2NDCHAR;
611}
612
613static uint8_t ens(struct ge *ge) {
614 return ge->rFO == ENS_OPCODE && (ge->rL1 & 0xFF) ==ENS_2NDCHAR;
615}
616
617static uint8_t loff(struct ge *ge) {
618 return ge->rFO == LOFF_OPCODE && (ge->rL1 & 0xFF) ==LOFF_2NDCHAR;
619}
620
621static uint8_t jc_js1_js2_jie_condition_verified(struct ge *ge) {
622 return ge->AVER && jc_js1_js2_jie(ge);
623}
624
625static uint8_t nop(struct ge *ge) {
626 return ge->rFO == NOP2_OPCODE;
627}
628
629static uint8_t is_jrt(struct ge *ge) {
630 return ge->rFO == JRT_OPCODE;
631}
632
633/* PM/SI immediate-format data ops executed in beta via the ALU helpers.
634 * After operand fetch these arrive in beta with V1=address, L1=immediate. */
635static uint8_t is_mvi(struct ge *ge) { return ge->rFO == MVI_OPCODE; }
636static uint8_t is_ni (struct ge *ge) { return ge->rFO == NI_OPCODE; }
637static uint8_t is_oi (struct ge *ge) { return ge->rFO == OI_OPCODE; }
638static uint8_t is_cmi(struct ge *ge) { return ge->rFO == CMI_OPCODE; }
639static uint8_t is_xi (struct ge *ge) { return ge->rFO == XI_OPCODE; }
640static uint8_t is_tm (struct ge *ge) { return ge->rFO == TM_OPCODE; }
641static uint8_t pm_imm_exec(struct ge *ge) {
642 return is_mvi(ge) || is_ni(ge) || is_oi(ge) || is_cmi(ge) || is_xi(ge) || is_tm(ge);
643}
644
645/* PM register ops (change registers, memory-mapped at 240+N*2): arrive in
646 * beta with V1=I1 address, L1=register-code aux char. */
647static uint8_t is_lr (struct ge *ge) { return ge->rFO == LR_OPCODE; }
648static uint8_t is_mvc(struct ge *ge) { return ge->rFO == MVC_OPCODE; }
649static uint8_t is_cmc(struct ge *ge) { return ge->rFO == CMC_OPCODE; }
650static uint8_t is_xc (struct ge *ge) { return ge->rFO == XC_OPCODE; }
651static uint8_t is_xoc_nc(struct ge *ge) {
652 return ge->rFO == XC_OPCODE || ge->rFO == OC_OPCODE ||
653 ge->rFO == NC_OPCODE;
654}
655static uint8_t is_oc_or_nc(struct ge *ge) {
656 return ge->rFO == OC_OPCODE || ge->rFO == NC_OPCODE;
657}
658static uint8_t is_xc_or_oc(struct ge *ge) {
659 return ge->rFO == XC_OPCODE || ge->rFO == OC_OPCODE;
660}
661static uint8_t not_FA03(struct ge *ge) { return !BIT(ge->ffFA, 3); }
662/* SS byte-loop terminal count: L1 low byte underflowed to all ones — the
663 * same convention as the channel length (RL1U1): the loop runs L1+1 times. */
664static uint8_t L1_21_ones(struct ge *ge) { return (ge->rL1 & 0xff) == 0xff; }
665
666/* L1's count byte is TWO independent quartet counters, not one 8-bit one.
667 * The user's wire trace of cp06 ch.096 settled it: the CI42 "count from 04"
668 * path drives the two L1 quartets from separate carry chains, so a sheet that
669 * names {L1_2 = 1i} or {L1_1 = 1i} is naming one quartet, and {L1_2,1 = 1i}
670 * (the single-length byte loops above) is naming both.
671 *
672 * Which quartet is which is not a guess: msl-commands.c records that the
673 * MVQ/CMQ field length is the HIGH nibble (alen), pinned by funktionalcpu
674 * step 0x1B (MVQ 2,0x0531,0x0533 with L1=0x01 moves exactly one byte), and
675 * fo.143 makes {L1_2 = 1i} the MVQ exit gate. So L1_2 is the high quartet
676 * (operand 1 / destination length) and L1_1 the low (operand 2 / source),
677 * which is also the SS2 instruction layout the disassembler already uses.
678 *
679 * L1_2 gates the algebra family's 40|42 exit (CU07, fo.143) and L1_1 reaches
680 * CI73 through EG43A's L1U16 input (cp06 ch.264 g5 + ch.068 g5, where both
681 * quartet terminals are built in the open: L1UI6 = low all-ones, L1UM6 =
682 * high all-ones). */
683static uint8_t L1_2_ones(struct ge *ge) { return (ge->rL1 & 0xf0) == 0xf0; }
684static uint8_t L1_1_ones(struct ge *ge) { return (ge->rL1 & 0x0f) == 0x0f; }
685
686/* The two-length algebra family, cp07 fo.140-143: one set of sheets for all
687 * six opcodes (docs/transcriptions/ab-sb-ad-sd-mvq-cmq.md). Both operands
688 * walk DESCENDING -- LSB first, for the URPE carry chain -- and the two L1
689 * quartets are two independent lengths: the low quartet counts operand 2 and
690 * its terminal drives the zero-extension (CI73 -> FA03 -> source-fetch
691 * inhibit), the high quartet counts operand 1 and drives the CU07 exit. */
692static uint8_t beta_algebra(struct ge *ge) {
693 switch (ge->rFO) {
694 case AB_OPCODE: case SB_OPCODE:
695 case AD_OPCODE: case SD_OPCODE:
696 case MVQ_OPCODE: case CMQ_OPCODE:
697 return 1;
698 default:
699 return 0;
700 }
701}
702/* The family terms fo.142/fo.143 print on the multiplexed rows. */
703static uint8_t is_ad_sd_cmq(struct ge *ge) { /* {AD+SD+CMQ} */
704 return ge->rFO == AD_OPCODE || ge->rFO == SD_OPCODE ||
705 ge->rFO == CMQ_OPCODE;
706}
707static uint8_t is_sd_sb_cmq(struct ge *ge) { /* {SD+SB+CMQ} */
708 return ge->rFO == SD_OPCODE || ge->rFO == SB_OPCODE ||
709 ge->rFO == CMQ_OPCODE;
710}
711static uint8_t is_ad_sd_cmq_mvq(struct ge *ge) { /* {AD+SD+CMQ+MVQ} */
712 return is_ad_sd_cmq(ge) || ge->rFO == MVQ_OPCODE;
713}
714static uint8_t is_ab_sb(struct ge *ge) { /* {AB+SB} */
715 return ge->rFO == AB_OPCODE || ge->rFO == SB_OPCODE;
716}
717static uint8_t not_cmq(struct ge *ge) { return ge->rFO != CMQ_OPCODE; }
718
719/* MVQ is the one family that walks 50|52 with nothing for the arithmetic
720 * unit to do, which is why fo.142's CI68 is the one common row it excludes. */
721static uint8_t not_mvq(struct ge *ge) { return ge->rFO != MVQ_OPCODE; }
722
723/* fo.143's flag conditions. {(URPE)} on CI74; the CI75 zero test is split
724 * by sub-family -- the binary ops test the whole result byte, the decimal/
725 * quartet ops only the DIGIT quartet ({/(dRO_1=0i)}, subscript printed), so
726 * the preserved zone nibble cannot make a zero result look nonzero. At
727 * TI06 of 40|42 the result byte is in RO (CI32 latched it at TO50). */
728static uint8_t urpe_set(struct ge *ge) { return ge->URPE; }
729static uint8_t ro_byte_nonzero(struct ge *ge) { return ge->rRO != 0; }
730static uint8_t ro_digit_nonzero(struct ge *ge) {
731 return (ge->rRO & 0x0f) != 0;
732}
733
734static uint8_t not_str(struct ge *ge) { return ge->rFO != STR_OPCODE; }
735static uint8_t not_cmr(struct ge *ge) { return ge->rFO != CMR_OPCODE; }
736static uint8_t is_smr_or_cmr(struct ge *ge) {
737 return ge->rFO == SMR_OPCODE || ge->rFO == CMR_OPCODE;
738}
739/* Pass 2 of the executive byte loop = the state's own X bit (62/52/42). */
740static uint8_t SA01_pass2(struct ge *ge) { return BIT(ge->rSA, 1); }
741static uint8_t SA01_pass1(struct ge *ge) { return !BIT(ge->rSA, 1); }
742static uint8_t is_str(struct ge *ge) { return ge->rFO == STR_OPCODE; }
743static uint8_t is_cmr(struct ge *ge) { return ge->rFO == CMR_OPCODE; }
744static uint8_t is_amr(struct ge *ge) { return ge->rFO == AMR_OPCODE; }
745static uint8_t is_smr(struct ge *ge) { return ge->rFO == SMR_OPCODE; }
746static uint8_t is_la (struct ge *ge) { return ge->rFO == LA_OPCODE; }
747static uint8_t is_lpsr(struct ge *ge) { return ge->rFO == LPSR_OPCODE; }
748static uint8_t pm_reg_exec(struct ge *ge) {
749 return is_lr(ge) || is_str(ge) || is_cmr(ge) || is_amr(ge) || is_smr(ge) || is_la(ge);
750}
751
752static uint8_t beta_jump_control(struct ge *ge) {
753 return (!is_jrt(ge) && jc_js1_js2_jie(ge)) || lon_loll(ge) ||
754 loff(ge) || ins(ge) || ens(ge) || nop(ge) ||
755 ge->rFO == HLT_OPCODE;
756}
757
758static uint8_t beta_register(struct ge *ge) {
759 return is_lr(ge) || is_str(ge) || is_cmr(ge) || is_amr(ge) || is_smr(ge);
760}
761
762static uint8_t beta_register_arithmetic(struct ge *ge) {
763 return is_cmr(ge) || is_amr(ge) || is_smr(ge);
764}
765
766static uint8_t beta_immediate_logic(struct ge *ge) {
767 return is_ni(ge) || is_oi(ge) || is_xi(ge) || is_tm(ge);
768}
769
770static uint8_t beta_immediate_shift(struct ge *ge) {
771 return is_mvi(ge) || beta_immediate_logic(ge) || is_cmi(ge);
772}
773
774static uint8_t immediate_and_mode(struct ge *ge) {
775 return is_ni(ge) || is_oi(ge) || is_tm(ge);
776}
777
778static uint8_t immediate_xor_or_mode(struct ge *ge) {
779 return is_xi(ge) || is_oi(ge);
780}
781
782static uint8_t immediate_writes_memory(struct ge *ge) { return !is_tm(ge); }
783static uint8_t immediate_sets_cc(struct ge *ge) {
784 return is_oi(ge) || is_xi(ge) || is_tm(ge);
785}
786static uint8_t immediate_nonzero_cc(struct ge *ge) {
787 return immediate_sets_cc(ge) && (ge->rRO & 0xff) != 0;
788}
789static uint8_t cmi_result_nonzero(struct ge *ge) { return (ge->rRO & 0xff) != 0; }
790static uint8_t cmi_borrow(struct ge *ge) { return !ge->URPE; }
791
793 return jc_js1_js2_jie(ge) || lon_loll(ge) || loff(ge) || ins(ge) || ens(ge) || nop(ge)
795}
796
797/* PER - PERI: conditions from fo. 46 */
798
799static uint8_t per_peri(struct ge *ge) {
800 return ((ge->rFO == PER_OPCODE) ||
801 (ge->rFO == PERI_OPCODE) ||
802 (ge->rFO == RDC_OPCODE));
803}
804
805static uint8_t per_peri_TO25_CO30(struct ge *ge) {
806 return per_peri(ge) && !BIT(ge->rFO, 1);
807}
808
809/* Artificial beta exit for the SS one-shot.
810 *
811 * The real machine runs the SS data operations through the executive band
812 * (64 -> 60|62 -> 50|52 -> 40|42 -> E2), and CM01A0 correctly withholds CU01
813 * from every SS opcode in beta because the loop, not the beta phase, is what
814 * eventually returns to alpha. gemu's EXEC_SS one-shot performs the whole
815 * instruction inside 64|65, so it has to synthesise the return that the
816 * executive states would otherwise have made. Delete this the moment the
817 * family is converted -- it is the marker for where the hybrid still is. */
818/* Defined with the executive and EA/EB charts further down; the beta chart
819 * needs them here. */
820static uint8_t ss_byte_loop(struct ge *ge);
821static uint8_t is_jrt_or_la(struct ge *ge);
822
823static uint8_t ss_hybrid_family(struct ge *ge) {
824 /* is_ss_data_op still lists MVC, XC, OC, NC, CMC and the six algebra
825 * opcodes, which now have real per-clock executive states. The old
826 * variant matrix hid the overlap by checking those families first; with
827 * the dispatch gone the exclusion has to be explicit, or a converted
828 * opcode would run the one-shot AND the executive loop -- producing
829 * correct results in far too few cycles, the exact failure the deck's
830 * cycle count caught. */
831 return is_ss_data_op(ge) && !ss_byte_loop(ge) && !beta_algebra(ge);
832}
833
834static uint8_t ss_hybrid_exit(struct ge *ge) {
835 return ss_hybrid_family(ge) && !per_peri(ge);
836}
837
838/* EPER "examine" operation: Z character (in L2) = 0xC0 (bits 7,6 set).
839 * (TPER read Z=0x00 -> bit7=0; "set by-pass" Z=0x80 -> bit6=0.) */
840static uint8_t is_eper_examine(struct ge *ge) {
841 return BIT(ge->rL2, 7) && BIT(ge->rL2, 6);
842}
843
844/* Beta phase instruction sheets.
845 *
846 * CPU[7] prints multiple 64|65 timing sheets, selected by the instruction
847 * decode matrix. They are one MSL, not several: the sheets differ only where
848 * a row carries a family term, and every sheet reprints the rows that do not.
849 * Those go in beta_64_common below and run for every instruction entering the
850 * state; each array that follows carries only what the decode multiplexes, so
851 * it reads as the DELTA against the physical sheet rather than the whole page.
852 *
853 * Some rows remain to be transcribed; the EXEC rows are temporary markers
854 * pending the downstream datapath commands described below and in
855 * docs/flowchart-sheets.md. */
856
857/* Rows every 64|65|66 sheet prints, with no family term on any of them: the
858 * beta phase always clears the two future-state bits that route it out of
859 * 0110 01XX. CU10 (reset S000) retires the X bit -- beta is entered as 64 or
860 * 65 depending on the alpha exit, and neither successor keeps bit 0 -- and
861 * CU12 (reset S002) drops the 0x04 that distinguishes beta from the executive
862 * and alpha bands. Whichever CU0x SETS follow from the variant then name the
863 * successor: +CU01+CU07 -> E2 (return to alpha), +CU03 -> EA (link/register
864 * write), +CU15+CU03 -> CC (external), none -> 60|62 (executive loop).
865 *
866 * Safe to hoist ahead of the variant rows: no 64|65 sheet issues CU00 or CU02,
867 * so no variant row contends with these two bits. */
868/* Every function class the beta sheets cover. Used only by the compatibility
869 * guard below -- with the dispatch table gone there is no "last variant", so
870 * "no sheet claimed this code" has to be said explicitly. */
871static uint8_t beta_known_family(struct ge *ge) {
872 return beta_jump_control(ge) || is_jrt(ge) || is_la(ge) || is_lpsr(ge) ||
875}
876static uint8_t beta_unclaimed(struct ge *ge) { return !beta_known_family(ge); }
877
878/* CO49 (reset URPE/URPU) is printed on every beta sheet except the external
879 * one, and on the control sheet is withheld from HLT -- which is why the
880 * jump-control term is an intersection rather than the bare family. */
887
888static const struct msl_timing_chart beta_64[] = {
889 /* Branch-address path. jc_js1_js2_jie covers JRT as well, so the control
890 * sheet's rows and the JRT sheet's are literally the same three rows --
891 * the dispatch table was keeping two copies of them. */
892 { TO10, CO10, jc_js1_js2_jie }, /* PO -> NO (return / branch address) */
893 { TO30, CI12, jc_js1_js2_jie }, /* V2 -> NO (jump target) */
894 { TO40, CO01, jc_js1_js2_jie }, /* NI -> V1 */
895
896 /* Change-register address build, 1111 nnn 1 = 241+2N. Shared verbatim by
897 * LA and the register family, which together are exactly pm_reg_exec.
898 * The gated forcings are an OPERAND-FIELD multiplex, not an opcode one:
899 * {LI06}/{LI05}/{LI04} are L1 bits 6-4, the register number, read one bit
900 * per NO position. CO90 is ungated -- a cell's LOW byte is always odd. */
901 { TO10, CO18, pm_reg_exec }, /* forcing in NO21 */
902 { TO10, CO97, pm_reg_exec },
903 { TO10, CO96, pm_reg_exec },
904 { TO10, CO95, pm_reg_exec },
905 { TO10, CO94, pm_reg_exec },
906 { TO10, CO93, pm_reg_exec, LI06 }, /* N2 -> NO03 */
907 { TO10, CO92, pm_reg_exec, LI05 }, /* N1 -> NO02 */
908 { TO10, CO91, pm_reg_exec, LI04 }, /* N0 -> NO01 */
909 { TO10, CO90, pm_reg_exec }, /* 1 -> NO00: odd (low) byte */
910
911 /* External operations build their own address; FO bit 1 (inside
912 * per_peri_TO25_CO30) separates PERI, which fetches its order byte from
913 * memory, from the form that takes it off the channel. */
914 { TO10, CO18, per_peri },
915 { TO10, CO95, per_peri, DE07A0 },
916 { TO10, CO96, per_peri, DE07A0 },
917 { TO10, CO97, per_peri, DE07A0 },
918 { TO25, CO30, per_peri_TO25_CO30, DE08A0 },
919
920 /* Console and interrupt flip-flops: one opcode each, no address path. */
921 { TO20, CI87, lon_loll },
922 { TO20, CI77, ins },
923 { TO60, CO35, jie },
924 { TO70, CI78, ens },
925 { TO89, CI88, loff },
926
927 /* Immediate operand staging. */
928 { TO30, CI15, beta_immediate_shift }, /* L1 -> NO */
929 { TO50, CI33, beta_immediate_shift }, /* NO21 -> RO */
930 { TO70, CI60, beta_immediate_shift }, /* RO2 -> NI4 */
931 { TO70, CI65, beta_immediate_shift }, /* RO1 -> NI3 */
932
933 /* Where the built address lands. FO bit 3 alone splits STR (0xb4) from
934 * LR/AMR/SMR/CMR (0xbd-0xbf): same address, opposite direction. */
935 { TO40, CO02, is_la }, /* V2, for the EA/EB write walk */
936 { TO40, CO01, beta_register, not_str }, /* {/STR}: V1 = cell address */
937 { TO40, CO02, beta_register, is_str }, /* {STR}: V2 = cell address */
938
939 { TO65, CO49, beta_co49 }, /* reset URPE/URPU */
940 { TO65, EXEC_SS, ss_hybrid_family }, /* hybrid one-shot, see below */
941
942 { TO70, CI62, per_peri, DE07A0 },
943 { TO70, CI67, per_peri, DE07A0 },
944
945 /* {AVER.JC+JS1+JS2+JIE+JRT}: an unmatched jump falls through with V1 and
946 * PO untouched. */
948 { TI05, CI05, is_la }, /* NI -> L1 */
949 { TI05, CI05, beta_immediate_shift }, /* immediate byte -> L1 high */
950 { TI05, CI05, per_peri_TO25_CO30, DE08A0 },
951
952 /* Exit. CU10+CU12 are the state's own -- every beta clears the X bit and
953 * leaves the beta band -- and the CU SETS below name the successor:
954 * +CU01+CU07 -> E2, +CU03 -> EA, +CU15+CU03 -> CC, none -> 60|62. */
955 { TI06, CU10, 0 }, /* reset S000: retire the state X bit */
956 { TI06, CU12, 0 }, /* reset S002: leave the beta band */
957 { TI06, CU01, CM01A0 }, /* cp06 ch.252-7, four-leaf partial cmd */
958 { TI06, CU07, CM01A0 },
959 { TI06, CU03, is_jrt_or_la }, /* -> EA: link / register-cell write */
960 { TI06, CU15, is_lpsr }, /* -> C2 */
961 { TI06, CU07, per_peri, DE07A0 },
962 { TI06, CU15, per_peri }, /* -> CC */
963 { TI06, CU03, per_peri },
964
965 /* The two rows that are NOT transcriptions. ss_hybrid_exit synthesises
966 * the return the executive loop would make -- CM01A0 rightly withholds
967 * CU01 from every SS opcode -- and beta_unclaimed is the aa7ed63
968 * swept-core guard. Both go when the SS families are converted and the
969 * CU10/CU12 partial commands are transcribed. */
970 { TI06, CU01, ss_hybrid_exit },
971 { TI06, CU07, ss_hybrid_exit },
972 { TI06, CU01, beta_unclaimed },
973 { TI06, CU07, beta_unclaimed },
974 { END_OF_STATUS, 0, 0 },
975};
976
977/* CPU[7] fo.9 + fo.10: JS1/JS2/JIE/JC/NOP2/HLT/INS/ENS/LON/LOFF/LOLL. */
978/* cp07 fo.33: JRT beta sheet, verified row-by-row. V1 ends up holding the
979 * RETURN address (CO10 PO->NO at TO10 -> BO at TO20 -> CO01 at TO40) and PO
980 * the jump target (CI12 V2->NO at TO30 -> BO relatch at TO50 -> CI00 {AVER
981 * JRT} at TI05). The link write itself happens in EA/EB (fo.34/35), reached
982 * via CU03: the forced address 0xFF/0xFE = change register 7. */
983/* cp07 fo.36: LA beta sheet. The forcings build the change-register LOW-byte
984 * address 1111 nnn 1 (= 241+2N, N = L1 bits 6-4 via {LI06}/{LI05}/{LI04})
985 * onto NO21; CO02 stores it to V2 for the EA/EB write walk. V1 keeps the
986 * operand EA from alpha — it is the DATUM the EA/EB states write into the
987 * register cell. (CI89 SET ALTO {FUL4} not modeled. The printed CI41/CI42
988 * "CONTA DA 00/04" rows are NOT carried: they configure the CI-side counting
989 * network gemu does not model yet, and routing them through the single CN
990 * would corrupt the forced address; the net V2 result — the register-cell
991 * low-byte address — is produced by the passthrough.) */
992/* cp07 fo.27: LPSR beta sheet (CI89 SET ALTO {FUL4} not modeled: FUL4
993 * strapping unimplemented). */
994/* cp07 fo.37: LR-AMR-SMR-CMR-STR beta sheet. The forcings build the
995 * change-register low-byte address 1111 nnn 1 (N = L1 bits 6-4); CO01
996 * {/STR} = DE04A0 (family & FO03: STR is 0xb4, the others 0xbd-0xbf, so
997 * bit 3 alone splits them) loads it into V1 for the non-STR ops — their
998 * WRITE/target side — while V2 keeps the operand EA from alpha as the
999 * SOURCE side; CO02 {STR} = DE05A0 does the reverse for STR. CI05's
1000 * loop-counter init and the CI41/CI42 rows are not carried: the pass
1001 * counter is architecturally visible as the state's own X bit (60/62,
1002 * 50/52, 40/42 -- pass 1 vs pass 2), which the 40|42 exit rows drive
1003 * (CU01 sets it looping back, CU07 {pass 2} leaves). CI89 {FUL4} not
1004 * modeled. */
1005/* CPU[7] fo.12 plus CMI/CHI sheet: immediate logical operations. */
1006/* CPU[7] fo.44-45: currently implemented executive data operations. */
1007/* CPU[7] fo.13: PER/PERI preliminary beta sheet. */
1008/* Compatibility route for undocumented function codes. This is intentionally
1009 * explicit: the cp06 DE00A transcription is incomplete and aa7ed63 established
1010 * that swept-core bytes must not wedge the emulator. */
1011static uint8_t xc_first_pass(struct ge *ge) {
1012 return is_xc(ge) && SA01_pass1(ge);
1013}
1014static uint8_t xc_byte_nonzero(struct ge *ge) {
1015 return is_xc(ge) && ge->rUA != 0;
1016}
1017static uint8_t cmc_byte_differs(struct ge *ge) { return ge->rUA != 0; }
1018static uint8_t cmc_borrow(struct ge *ge) { return !ge->URPE; }
1019static uint8_t cmc_done(struct ge *ge) {
1020 return L1_21_ones(ge) || ge->rUA != 0;
1021}
1022
1023/* XC-OC-NC (cp07 fo.144-147) and CMC (fo.76-79), verified row-by-row.
1024 * Both share the MVC-style byte loop (source byte staged at V2++ in 60|62
1025 * with the CI-phase length count, result/write at V1++ in 40|42); the logic
1026 * family adds the 50|52 UA pass with the mode selectors exactly as gemu's
1027 * CI68 table expects (CI45 logic + CI46 {OC+NC} + CI47 {XC+OC}: XC=xor,
1028 * OC=or, NC=and), and CMC's 50|52 is a per-byte compare: CO48 presets the
1029 * borrow EVERY pass, CI68 subtracts (op1 byte - op2 byte), and 40|42 exits
1030 * early on the first difference {(L1_2,1=1i) + /(dRO=0i)} with the flags of
1031 * that pass: FI04 armed on the first byte (CI74 {/SA01}) and reset on
1032 * borrow {/URPE}, FI05 set on a differing byte {/(dRO=0)} -- the FA04/FA05
1033 * pair lands on the manual's compare table (equal=2, low=1, high=3). */
1034
1035/* MVC (cp07 fo.73/74/75, verified row-by-row): the SS byte-copy loop.
1036 * beta contributes only CO49 + the exit to 60|62 (all datapath rows on the
1037 * shared sheet are {MVI}-gated); 60|62 reads the source byte at V2++ and
1038 * stages it in L1's high byte while the CI-phase count decrements the
1039 * length in L1's low byte (CI40+CI44+CI41: -1, byte-local); 40|42 writes
1040 * the staged byte at V1++ and loops {/(L1_2,1=1i)} back to 60+62 or exits
1041 * to E2/E3 on the terminal count {L1_2,1=1i} (overbar placement verified
1042 * at high zoom: the loop condition carries the full-expression overbar). */
1043/* Register-family executive states, cp07 fo.38/39/40, verified row-by-row.
1044 * Two passes over the 16-bit quantities, low byte then high byte, encoded in
1045 * the state X bit: 60 -> (50) -> 40 -> 62 -> (52) -> 42 -> E2/E3, with
1046 * LR/STR skipping 50|52 (CU04 set + CU14 {LR+STR} reset). Per pass:
1047 * 60|62 reads the SOURCE byte at V2-- (memory operand for the non-STR ops,
1048 * the register cell for STR) and stages it in L1's high byte (CI60/CI65 +
1049 * CI05); 50|52 (arithmetic only) reads the register byte at V1, runs the UA
1050 * (CI47 subtract for SMR/CMR, CO48 {/SA01} presets the borrow on pass 1,
1051 * URPE carries between passes) and restages the result; 40|42 writes the
1052 * staged byte to V1-- ({LR+AMR+SMR+STR} -- CMR writes nothing) and sets the
1053 * qualitative flags: FI04 = pass carry (CI84 re-arms it each pass in 60|62),
1054 * FI05 = result zero accumulated across passes (CI85 arms on pass 1 only).
1055 * The printed 40|42 exit gate is {(L1_2=1i)}, the loop counter the CI41/42
1056 * init rows feed; the state X bit is the architecturally equivalent pass
1057 * encoding gemu uses while that counter init remains undecoded. */
1058
1059static uint8_t reg_arith_pass1(struct ge *ge) {
1061}
1062
1063static uint8_t beta_register_lr_str(struct ge *ge) {
1064 return is_lr(ge) || is_str(ge);
1065}
1066
1067static uint8_t reg_arith50_pass1_sub(struct ge *ge) {
1068 return is_smr_or_cmr(ge) && SA01_pass1(ge);
1069}
1070
1071static uint8_t reg_result_nonzero(struct ge *ge) {
1072 /* {/(dRO=0i).(AMR+SMR+CMR)} -- the sheet's condition is OVERBARRED:
1073 * set FI05 when the pass result byte is NONZERO. CI85 arms (resets)
1074 * FI05 on pass 1, so the two passes OR into it: FA05 = result != 0,
1075 * exactly the manual's CC tables (cp04 sec.5.6.4.2-4), where the
1076 * carry/nonzero pair encodes compare results for CMR (unsigned) and
1077 * SMR (signed, two's complement) alike. */
1078 return beta_register_arithmetic(ge) && ge->rUA != 0;
1079}
1080
1081static uint8_t reg_carry(struct ge *ge) {
1082 return beta_register_arithmetic(ge) && ge->URPE;
1083}
1084
1085/* The executive states.
1086 * -------------------
1087 * A fetch/operate/store pipeline that every family walks the same way, and
1088 * the sheets show it: the shared rows are printed with no family term on any
1089 * of the sheets listed in chart_ref, so they belong to the state rather than
1090 * to the instruction. What the decode multiplexes is only WHERE the byte
1091 * comes from, WHAT the arithmetic unit does to it, and WHEN the loop stops.
1092 *
1093 * Each state is ONE chart. The GE-120 has one micro-sequence logic per
1094 * state; the per-family sheets are that same gate network read through a
1095 * decode filter, printed once per family because the manual is organised by
1096 * family. So every row carries its own gate and there is no dispatch. */
1097
1098static const struct msl_timing_chart exec_50[] = {
1099 /* Shared skeleton -- every family that enters 50|52 walks it identically:
1100 * read the operand-1 byte at V1, put the byte 60|62 staged onto NO so it
1101 * reaches BO, run the arithmetic unit, restage the result, hand on. */
1102 { TO10, CO11, 0 }, /* V1 -> NO: operand-1 address */
1103 { TO25, CO30, 0 }, /* MEM -> RO: operand-1 byte */
1104 { TO30, CI15, 0 }, /* L1 -> NO: staged byte reaches BO */
1105
1106 /* UA mode. This is the ONLY thing the decode multiplexes in this state,
1107 * and each row carries the gate its own sheet prints -- no dispatch. */
1108 { TO30, CI45, beta_immediate_logic }, /* fo.43 logic unit */
1109 { TO30, CI46, immediate_and_mode }, /* fo.43 {NI+CI+TM} */
1110 { TO30, CI47, immediate_xor_or_mode }, /* fo.43 {XI+CI} */
1111 { TO30, CI45, is_xoc_nc }, /* fo.146 logic unit */
1112 { TO30, CI46, is_oc_or_nc }, /* fo.146 {OC+NC} */
1113 { TO30, CI47, is_xc_or_oc }, /* fo.146 {XC+OC} */
1114 { TO30, CI47, is_cmi }, /* fo.78 subtract */
1115 { TO30, CI47, is_cmc }, /* fo.78 subtract */
1116 /* fo.142: no CI45 on the sheet -- the family runs the UA in ARITHMETIC
1117 * mode, with CI46 selecting decimal and CI50 (below) narrowing it to
1118 * the digit quartet. AB/SB raise neither: plain binary add/subtract. */
1119 { TO30, CI46, is_ad_sd_cmq }, /* fo.142 {AD+SD+CMQ} decimal */
1120 { TO30, CI47, is_sd_sb_cmq }, /* fo.142 {SD+SB+CMQ} subtract*/
1121 { TO50, CO48, immediate_xor_or_mode }, /* fo.43 carry-in */
1122 { TO50, CO48, is_xc_or_oc }, /* fo.146 as printed */
1123 { TO50, CO48, is_cmi }, /* fo.78 complement add */
1124 { TO50, CO48, is_cmc }, /* fo.78 borrow EVERY byte */
1125 { TO50, CO48, reg_arith50_pass1_sub }, /* fo.39 {(SMR+CMR)./SA01} */
1126 /* fo.142 {(SD+CMQ+SB)./SA01}: the borrow is preset ONCE, on the first
1127 * iteration -- the X bit is set by CU01 from iteration 2 on -- and then
1128 * propagates digit to digit through URPE. (The brace was verified at
1129 * high zoom: the bar covers SA01 alone.) */
1130 { TO50, CO48, is_sd_sb_cmq, SA01_pass1 },
1131 { TO50, CI50, is_ad_sd_cmq }, /* fo.142 "WORK ONLY UA1" */
1132 { TO50, CI47, is_smr_or_cmr }, /* fo.39 subtract */
1133
1134 /* UA -> NI43, in the mode set above. Not quite a common row: fo.142
1135 * prints CI68 gated {(AD+SD+AB+SB+CMQ)} and MVQ is the one family that
1136 * enters 50|52 with nothing for the arithmetic unit to do -- it walks the
1137 * operate state purely to reach 40|42 with the byte staged. Every other
1138 * sheet reaching this state prints CI68 with no family term, so the gate
1139 * is written as the single exclusion rather than as five family rows. */
1140 { TO70, CI68, not_mvq },
1141 /* fo.142 {AD+SD+CMQ+MVQ}: RO2 -> NI4, the preserved ZONE nibble. The
1142 * row sits after CI68 because RO-in-NI has priority over UA-in-NI (cpu
1143 * fo.125/126) and gemu's array order realises that priority. For MVQ
1144 * -- which issues no CI68 -- NI3 keeps its counting-network default,
1145 * which at this point carries BO quartet 3 = the staged source DIGIT:
1146 * the knot's idle path IS the quartet move. */
1147 { TO70, CI60, is_ad_sd_cmq_mvq },
1148 { TI05, CI05, 0 }, /* restage result in L1 high byte */
1149 { TI06, CU14, 0 }, /* reset S004 -> 40|42 */
1150 { END_OF_STATUS, 0, 0 },
1151};
1152
1153/* 40|42 is the STORE-and-advance state. Common: address operand 1 (CO11),
1154 * put the staged byte back on NO (CI15), step V1 through the counting
1155 * network (CO01), and latch the byte into RO for the write (CI32). The two
1156 * unconditional CU sets are the loop arc -- CU01+CU05 turn 40|42 back into
1157 * 60|62 -- so a family LEAVES the loop by adding CU07 under its own terminal
1158 * condition, never by withholding these.
1159 *
1160 * Multiplexed per family, and deliberately not hoisted:
1161 * TO10 CO41/CO40 -- direction. Ascending for the SS byte loops, absent
1162 * for the single-byte immediates, descending (CO40) for the register
1163 * family, which walks 16-bit quantities LSB-first for the carry chain.
1164 * TO25 CO31 -- whether the byte is WRITTEN at all: CMR and CMC
1165 * compare without storing, TM tests without storing.
1166 * TI06 CU07 -- the terminal condition, different for every family
1167 * (state X bit for the register pair, L1 all-ones for MVC/XC, either
1168 * that or first-difference for CMC). */
1169/* The three SS byte loops step their destination pointer upward; the register
1170 * family walks 16-bit quantities downward, LSB first, for the carry chain. */
1171static uint8_t ss_byte_loop(struct ge *ge) {
1172 return is_mvc(ge) || is_cmc(ge) || is_xoc_nc(ge);
1173}
1174
1175static const struct msl_timing_chart exec_40[] = {
1176 /* Shared skeleton: address operand 1, put the staged byte back on NO,
1177 * step V1 through the counting network, latch the byte into RO. */
1178 { TO10, CO11, 0 }, /* V1 -> NO: operand-1 address */
1179 { TO30, CI15, 0 }, /* L1 -> NO: the staged result byte */
1180 { TO40, CO01, 0 }, /* NI -> V1: stepped address */
1181 { TO50, CI32, 0 }, /* NO43 -> RO: byte to write */
1182
1183 /* Direction of the step. */
1184 { TO10, CO41, beta_register }, /* V1 - 1 ... */
1185 { TO10, CO40, beta_register }, /* ...DESCENDING: LSB-first, for carry */
1186 { TO10, CO41, ss_byte_loop }, /* V1 + 1: ascending */
1187 { TO10, CO41, beta_algebra }, /* V1 - 1 ... */
1188 { TO10, CO40, beta_algebra }, /* ...DESCENDING: LSB-first (fo.143) */
1189
1190 /* Whether the byte is written at all: the compares never store, and TM
1191 * tests without storing. */
1192 { TO25, CO31, beta_register, not_cmr }, /* {LR+AMR+SMR+STR} */
1193 { TO25, CO31, beta_immediate_logic, immediate_writes_memory }, /* {/TM} */
1194 { TO25, CO31, is_mvi },
1195 { TO25, CO31, is_mvc },
1196 { TO25, CO31, is_xoc_nc },
1197 { TO25, CO31, beta_algebra, not_cmq }, /* fo.143 {AD+SD+MVQ+AB+SB} */
1198 /* CMI, CMC and CMQ issue no CO31 */
1199
1200 /* Condition-code flags. CI85 (reset FI05) is kept ahead of CI75 (set
1201 * FI05) because the immediate sheet prints them in that order and the
1202 * pair shares a flip-flop. */
1203 { TI06, CI85, immediate_sets_cc }, /* {CI+XI+TM}: NI sets no CC */
1204 { TI06, CI74, reg_carry }, /* {URPE.(A/S/CMR)} */
1205 { TI06, CI74, immediate_sets_cc },
1206 { TI06, CI75, reg_result_nonzero }, /* {/(dRO=0)} */
1207 { TI06, CI75, immediate_nonzero_cc },
1208 { TI06, CI75, is_cmi, cmi_result_nonzero },
1209 { TI06, CI75, is_cmc, cmc_byte_differs }, /* {/(dRO=0i)} */
1210 { TI06, CI75, xc_byte_nonzero }, /* {XC./(dRO=0i)} */
1211 /* fo.143: the zero test is quartet-local for the decimal/quartet ops
1212 * ({/(dRO_1=0i)}, subscript printed) and whole-byte for AB/SB. */
1213 { TI06, CI75, is_ab_sb, ro_byte_nonzero },
1215 { TI06, CI74, beta_algebra, urpe_set }, /* fo.143 {(URPE)} */
1216 /* fo.143 prints CI73 with an EMPTY cell and CU01 with {(L1_1 = 1i)};
1217 * both are wrong by one row. CI73's leaf EG43A = NAND(DI493, DO211,
1218 * L1U16, DO211) (cp06 ch.264 g5) carries the low quartet's all-ones
1219 * terminal (L1U16, ch.068 g5), and CU01's chain has no counter term at
1220 * all (ch.219 g1 -> ch.252 g8 -> ch.222 g1, all state decodes; ch.239
1221 * verified against the found paper sheet). So: FI03 latches "operand 2
1222 * exhausted" here, and FA03 inhibits the source fetch from the next
1223 * 60|62 on -- the zero-extension. */
1224 { TI06, CI73, beta_algebra, L1_1_ones },
1225 { TI06, CI84, is_cmi, cmi_borrow },
1226 { TI06, CI84, is_cmc, cmc_borrow }, /* {/URPE} */
1227
1228 /* The loop arc: CU01+CU05 turn 40|42 back into 60|62, so a family LEAVES
1229 * by ADDING CU07 under its own terminal condition, never by withholding
1230 * these. Every terminal gate below is a different one. */
1231 /* CU01 is unconditional, including on fo.143, which prints a
1232 * {(L1_1 = 1i)} brace against it. That brace is a sheet error: the gate
1233 * chain was traced end to end in cp06 and contains no counter term --
1234 * CU011 = NAND(CM01A, CM02A, DE53A, ED36A, ED10A, ED84A, ED66A, ED50A)
1235 * (ch.219 g1), CM021 = NAND(DI49A, DI36B, DI57B, DI94A, DI60A, DI13A,
1236 * DI50A) (ch.252 g8), and DI49A = NAND(DI481, SA066) (ch.222 g1, the
1237 * 40|42 decode itself). All seven CM021 leaves are verified state
1238 * decodes -- DI60A's chapter (ch.239) is missing from the scan, so its
1239 * gate was reconstructed from the cp08 card layout instead (board
1240 * A16+B16, a LOSE2M like ch.248's, template pin-matched 16/16):
1241 * DI60A = NAND(DI121, SA028), confirmed by ch.252 g11 printing DI121's
1242 * fan-out as (239-12). Full leaf audit and board reconstruction in
1243 * docs/transcriptions/ab-sb-ad-sd-mvq-cmq.md. */
1244 { TI06, CU01, 0 },
1245 { TI06, CU05, 0 },
1246 { TI06, CU07, beta_register, SA01_pass2 }, /* pass 2 done */
1247 { TI06, CU07, is_mvc, L1_21_ones }, /* {L1_2,1=1i} terminal */
1248 { TI06, CU07, is_xoc_nc, L1_21_ones },
1249 { TI06, CU07, is_cmc, cmc_done }, /* {(L1=1i)+/(dRO=0i)} */
1250 { TI06, CU07, beta_algebra, L1_2_ones }, /* fo.143 {(L1_2 = 1i)} */
1251 { TI06, CU07, beta_immediate_shift }, /* single byte: always */
1252 { TI06, CU10, beta_immediate_shift },
1253 { TI06, CU12, beta_immediate_shift },
1254 { END_OF_STATUS, 0, 0 },
1255};
1256
1257/* Families that fetch a source byte in 60|62. MVI, the immediate logicals
1258 * and CMI use the state purely for routing and touch no datapath at all. */
1259static uint8_t exec60_fetches_source(struct ge *ge) {
1261}
1262
1263/* CU04 (set S004) is issued by everything except MVI, which has nothing for
1264 * the UA to do and lets the bare CU15 route 60 straight through to 40. */
1265static uint8_t exec60_sets_S004(struct ge *ge) {
1267}
1268
1269static const struct msl_timing_chart exec_60[] = {
1270 /* Source fetch: address operand 2, read the byte, stage it in L1's high
1271 * half while the CI-phase network counts the length down in the low. */
1272 { TO10, CO12, exec60_fetches_source }, /* V2 -> NO: source address */
1273 { TO10, CO41, exec60_fetches_source }, /* count from 00 */
1274 { TO10, CO40, beta_register }, /* DESCENDING: register only... */
1275 { TO10, CO40, beta_algebra }, /* ...and algebra: LSB-first */
1276 { TO25, CO30, beta_register }, /* MEM -> RO: source byte */
1277 { TO25, CO30, is_mvc },
1278 { TO25, CO30, is_cmc },
1279 { TO25, CO30, is_xoc_nc, not_FA03 }, /* {/FA03} */
1280 /* fo.141 {/FA03}: once operand 2's quartet ran out, CI73 set FI03 in
1281 * 40|42 and the source fetch is inhibited -- the family's
1282 * zero-extension. RO reads 0 (TO20 clears it), so the remaining
1283 * operand-1 digits are processed against nothing. */
1284 { TO25, CO30, beta_algebra, not_FA03 },
1285 { TO30, CI15, exec60_fetches_source }, /* L1 -> NO (count path) */
1286 { TO30, CI40, exec60_fetches_source }, /* CI-phase: decreasing */
1287 { TO30, CI44, exec60_fetches_source }, /* ...stop 07, byte-local */
1288 { TO30, CI41, exec60_fetches_source }, /* ...count from 00 */
1289 { TO30, CI42, beta_register }, /* ...and from 04: register only */
1290 { TO30, CI42, beta_algebra }, /* algebra: BOTH quartets count */
1291 { TO40, CO02, exec60_fetches_source }, /* NI -> V2: stepped address */
1292 { TO70, CI65, exec60_fetches_source }, /* RO1 -> NI3 */
1293 { TO70, CI60, exec60_fetches_source }, /* RO2 -> NI4: stage the byte */
1294 { TI05, CI05, exec60_fetches_source }, /* L1 = [byte][counted low] */
1295
1296 /* Condition-code arming. Done here, once per pass, because 40|42 is
1297 * where the flags are written and it must find them primed. */
1298 { TI06, CI74, is_cmi },
1299 { TI06, CI74, is_cmc, SA01_pass1 }, /* {/SA01} */
1300 { TI06, CI74, xc_first_pass }, /* {/SA01.XC} */
1301 { TI06, CI85, is_cmi },
1302 { TI06, CI85, is_cmc, SA01_pass1 },
1303 { TI06, CI85, xc_first_pass },
1304 { TI06, CI85, reg_arith_pass1 }, /* {/SA01.(AMR+SMR+CMR)} */
1305 /* fo.141 prints CI85 with an EMPTY condition cell and CI84 with
1306 * {/SA01}; the gates say the brace belongs one row up. CI85's leaf
1307 * DE91A = NAND(DI052, SA01M, DO381) (cp06 ch.249 g3) carries the
1308 * negated X-bit rail, so FI05 is ARMED ONCE, first iteration, and then
1309 * accumulates "digit nonzero" -- the only reading that yields the
1310 * documented CC tables. CI84 re-arms each iteration so FA04 ends as
1311 * the FINAL carry/borrow, exactly as the deck-validated register
1312 * family already does. */
1313 { TI06, CI85, beta_algebra, SA01_pass1 },
1314 { TI06, CI84, beta_register_arithmetic },/* re-arm FI04 each pass */
1315 { TI06, CI84, beta_algebra }, /* re-arm: FA04 = final carry */
1316
1317 /* Exit. CU15 always leaves the 6x band; CU04 then decides whether the
1318 * successor is the operate state, and the families with nothing for the
1319 * UA to do reset it straight back out. */
1320 { TI06, CU15, 0 }, /* reset S005: leave 6x */
1321 { TI06, CU04, exec60_sets_S004 },
1322 { TI06, CU14, beta_register_lr_str }, /* {LR+STR}: skip 50|52 */
1323 { TI06, CU14, is_mvc }, /* MVC likewise: nothing to do */
1324 { END_OF_STATUS, 0, 0 },
1325};
1326
1327
1328
1329
1330/* Display */
1331/* ------- */
1332
1333static uint8_t state_00_TO10_CO10(struct ge *ge) { return AF32(ge) || AF42(ge); }
1334static uint8_t state_00_TO10_CO11(struct ge *ge) { return AF31(ge) || AF41(ge) || AF51(ge); }
1335/* CI33 (RO <- NO21) puts the low half of the displayed register on the RO lamps
1336 * -- for every position except the three length ones, which reach the knot at
1337 * TO30 instead, and except V1-LETT.
1338 *
1339 * V1-LETT is position 9, the memory READ: it fetches mem[V1] into RO, advances
1340 * V1, and "the byte read shows on the RO lamps" (CPU[4] §4.2, fo.35-37; the
1341 * rotary table in docs/console.md). A display cycle that reloaded RO from the
1342 * address knot would wipe that byte before the operator could read it -- and
1343 * does, now that the panel runs continuously as the iron's does: the byte
1344 * appears for one cycle and is replaced by the low half of the freshly
1345 * advanced V1. The position exists to show memory, so the display leaves RO
1346 * alone while it is selected. (Same family of misreading as CI15 above.) */
1347static uint8_t state_00_TO50_CI33(struct ge *ge)
1348{
1349 return !AF20(ge) && !AF21(ge) && !AF40(ge) && !AF51(ge);
1350}
1351
1352/* Flow chart 14023130A "DISPLAY SEQUENCE" (CPU[7] render-pg 24). Verified
1353 * row-by-row; the chart's `V3->BO [AF36]` is a scan artifact for `[AF30]`.
1354 *
1355 * The sequence has two halves and each rotary position belongs to exactly one:
1356 * TO10 routes the selected ADDRESS register into the NO knot (CO10..CO14), and
1357 * TO30 routes the selected LENGTH register there instead (CI15 = L1, CI17 = L3,
1358 * CI21 = R1/L2). TO50's CI33 (RO <- NO21) then completes the address half, and
1359 * its printed condition is the proof of the split: it fires for everything
1360 * EXCEPT L3, L1 and R1/L2 -- the three length positions.
1361 *
1362 * CI15 used to carry `!AF20 && !AF40` here, the complement of L3 and R1/L2 with
1363 * the L1 term dropped, which made it fire for every address position too and
1364 * overwrite the register TO10 had just routed. A chart row that unconditionally
1365 * destroys the row above it is a misreading, and this one had teeth: with the
1366 * rotary at NORM the knot reached state 80 holding L1, whose `CO00 PO <- NI`
1367 * then wrote it into the program addresser. An operator who keyed a start
1368 * address into PO and pressed START ran from the last program's L1 instead --
1369 * i.e. "you cannot change PO from the console", which you certainly can on the
1370 * real machine. Conditioned on AF21 (the L1 position) it matches CI33's own
1371 * exclusion list and the address positions survive. */
1372static const struct msl_timing_chart state_00[] = {
1373 { TO10, CO10, state_00_TO10_CO10 }, /* RS_NORM or RS_PO */
1374 { TO10, CO11, state_00_TO10_CO11 }, /* RS_V1 or RS_V1_SCR or RS_V1_LETT */
1375 { TO10, CO12, AF50 }, /* RS_V2 */
1376 { TO10, CO13, AF30 }, /* RS_V3 */
1377 { TO10, CO14, AF10 }, /* RS_V4 */
1378 /* V1-LETT reads. Position 9 shows the byte AT V1 on the RO lamps, and the
1379 * display cycle is a memory cycle like any other, so it fetches it: the
1380 * lamps then hold mem[V1] for as long as the position is selected, and
1381 * each START advances V1 to the next byte (the forcing chart's own
1382 * `TO25 CO30 [AF51]` row, which is where the advance happens). Without
1383 * this the byte the operator asked for lives exactly one cycle. */
1384 { TO25, CO30, AF51 }, /* RS_V1_LETT: read mem[V1] */
1385 { TO30, CI15, AF21 }, /* RS_L1 */
1386 { TO30, CI17, AF20 }, /* RES_L3 */
1387 { TO30, CI21, AF40 }, /* RS_R1_R2 */
1388 { TO30, CI16, AF40 }, /* RS_V1_SCR */
1389 { TO50, CI33, state_00_TO50_CI33 }, /* not RS_L3 and not RS_L1 and not RS_R1_L2 */
1390 { TI06, CU07, 0 },
1391 { END_OF_STATUS, 0, 0 }
1392};
1393
1394/* Forcing */
1395/* ------- */
1396
1397static uint8_t AF52_not_RO00(struct ge *ge) { return AF52(ge) && not_RO00(ge); }
1398static uint8_t AF52_not_RO01(struct ge *ge) { return AF52(ge) && not_RO01(ge); }
1399static uint8_t AF52_not_RO02(struct ge *ge) { return AF52(ge) && not_RO02(ge); }
1400static uint8_t AF52_not_RO03(struct ge *ge) { return AF52(ge) && not_RO03(ge); }
1401static uint8_t AF52_not_RO04(struct ge *ge) { return AF52(ge) && not_RO04(ge); }
1402static uint8_t AF52_not_RO05(struct ge *ge) { return AF52(ge) && not_RO05(ge); }
1403static uint8_t AF52_not_RO06(struct ge *ge) { return AF52(ge) && not_RO06(ge); }
1404static uint8_t AF52_not_RO07(struct ge *ge) { return AF52(ge) && not_RO07(ge); }
1405
1406/* Flow chart 14023130B "FORCING SEQUENCE" (CPU[7] render-pg 25). States match
1407 * + tests/forcing.c passes; a few forcing-read brackets (CO30/CO31/CI20/CI33)
1408 * need a higher-DPI/physical recheck (docs/flowchart-sheets.md). */
1409static const struct msl_timing_chart state_08[] = {
1410 { TO10, CO11, AF41, EC69A0 }, /* fo. 18 */
1411 { TO10, CO11, AF51 },
1412 { TO10, CO41, 0 },
1413 { TO25, CO30, AF51 },
1414 { TO25, CO31, AF41 },
1415 { TO30, CI20, 0 },
1416 { TO40, CO01, AF41, EC69A0 },
1417 { TO40, CO01, AF51 },
1418 { TO50, CO48, AF52 },
1419 /* NO -> BO */
1420 { TO50, CI33, AF41 },
1421 { TO50, CI33, AF43 },
1422 { TO64, CO49, AF52_not_RO07 },
1423 { TO70, CI62, AF51, EC70A0 },
1424 { TO70, CI67, AF51 }, /* fo. 19 */
1425 { TI05, CI04, AF10 },
1426 { TI05, CI02, AF50 },
1427 { TI05, CI05, AF21 },
1428 { TI05, CI05, AF51 },
1429 { TI05, CI01, AF31 },
1430 { TI05, CI00, AF42 },
1431 { TI05, CI08, AF53 },
1432 { TI06, CI07, AF20 },
1433 { TI06, CI03, AF30 },
1434 { TI06, CI06, AF40 },
1435 { TI06, CI09, AF40 },
1436 { TI06, CI70, AF52 },
1437 { TI06, CI71, AF52 },
1438 { TI06, CI72, AF52 },
1439 { TI06, CI73, AF52 }, /* fo. 20 */
1440 { TI06, CI74, AF52 },
1441 { TI06, CI75, AF52 },
1442 { TI06, CI76, AF52 },
1443 { TI06, CI80, AF52_not_RO00 },
1444 { TI06, CI81, AF52_not_RO01 },
1445 { TI06, CI82, AF52_not_RO02 },
1446 { TI06, CI83, AF52_not_RO03 },
1447 { TI06, CI84, AF52_not_RO04 },
1448 { TI06, CI85, AF52_not_RO05 },
1449 { TI06, CI86, AF52_not_RO06 },
1450 { TI06, CU00, 0 },
1451 { TI06, CU01, 0, DI57B0 },
1452 { TI06, CU02, 0 },
1453 { TI06, CU03, 0, DI57B0 },
1454 { TI06, CU04, 0, DI57B0 },
1455 { TI06, CU05, 0 },
1456 { TI06, CU06, 0 },
1457 { TI06, CU07, 0, DI57A0 },
1458 { TI06, CU10, not_RO00 }, /* fo. 21 */
1459 { TI06, CU11, not_RO01 },
1460 { TI06, CU12, not_RO02 },
1461 { TI06, CU13, not_RO03 },
1462 { TI06, CU14, not_RO04 },
1463 { TI06, CU15, not_RO05 },
1464 { TI06, CU16, not_RO06 },
1465 { TI06, CU17, not_RO07 },
1466 { END_OF_STATUS, 0, 0 }
1467};
1468
1469/* PER - PERI */
1470/* ---------- */
1471
1472static uint8_t state_c8_TI06_CI85(struct ge *ge) {
1473 /* !(selected_connector_busy || selected_channel_busy) */
1474 return !(PUB01(ge) || DU92(ge));
1475}
1476
1477/* PER-PERI preliminary phase, flow chart 14023130F (CPU[7] render-pg 32).
1478 * State graph 64/65->c8->d8/d9/da/db->dc->cc and 80->(AINI)->c8|alpha verified
1479 * via the CUxx future-state arithmetic; tests/initial-load.c locks the per-state
1480 * register values. Peripheral-status decode (DU95/DU96/PCOV) is partial — PCOV
1481 * is stubbed to 1. See docs/flowchart-sheets.md. */
1482static const struct msl_timing_chart state_c8[] = {
1483 { TO10, CO12, 0, DI97A0 },
1484 { TO10, CO41, 0, DI97A0},
1485 { TO25, CO30, not_AINI, ED70A0},
1486 { TO40, CO02, 0, DI97A0 },
1487 { TO70, CI62, 0, DI25A0 },
1488 { TO70, CI67, 0, DI25A0 },
1489 { TI06, CI06, 0 },
1490 { TI06, CI75, 0, DI25A0 },
1491 { TI06, CI84, 0, DI25A0 },
1492 { TI06, CI85, state_c8_TI06_CI85 },
1493 { TI06, CU04, 0 },
1494 { END_OF_STATUS, 0, 0 },
1495};
1496
1497static uint8_t state_d8_TO19_CE02(struct ge *ge) {
1498 return !BIT(ge->ffFA, 5) && !BIT(ge->ffFA, 4);
1499}
1500
1501static uint8_t state_d8_TO40_CO00(struct ge *ge) {
1502 return BIT(ge->ffFA, 5) && !DU93(ge);
1503}
1504
1505static const struct msl_timing_chart state_d8[] = {
1506 { TO10, CO10, 0 },
1507 { TO10, CO40, 0, DI21A0 }, // NOTE: both commands have same conditions ?!
1508 { TO10, CO41, 0, DI21A0 }, // NOTE: it's like this in timing charts.
1509 { TO19, CE02, state_d8_TO19_CE02 },
1510 { TO30, CI15, 0, DI21A0 },
1511 { TO40, CO00, state_d8_TO40_CO00 },
1512 { TO50, CI33, 0, DI21A0 },
1513 { TO50 /* PIPO */, CE01, 0 },
1514 { TI06, CU00, 0, DI93A0},
1515 { END_OF_STATUS, 0, 0 },
1516};
1517
1518static uint8_t state_d9_TO40_CO00(struct ge *ge) {
1519 return BIT(ge->ffFA, 5) && !DU93(ge);
1520}
1521
1522static const struct msl_timing_chart state_d9[] = {
1523 { TO10, CO10, 0 },
1524 { TO10, CO40, 0, DI21A0 },
1525 { TO10, CO41, 0, DI21A0},
1526 { TO30, CI15, 0, DI21A0 },
1527 { TO40, CO00, state_d9_TO40_CO00 },
1528 { TO50, CI33, 0, DI21A0},
1529 { TI06, CU00, 0, DI93A0},
1530 { TI06, CU01, 0, DI94A0},
1531 { TI06, CU10, 0 },
1532 { END_OF_STATUS, 0, 0 },
1533};
1534
1535static const struct msl_timing_chart state_da[] = {
1536 { TO10, CO10, 0 },
1537 { TO10, CO40, 0, DI21A0 },
1538 { TO10, CO41, 0, DI21A0 },
1539 { TO30, CI15, 0, DI21A0 },
1540 { TO40, CO00, state_d9_TO40_CO00 },
1541 { TO50, CI33, 0, DI21A0 },
1542 { TI06, CU00, 0, DI93A0 },
1543 { END_OF_STATUS, 0, 0 },
1544};
1545
1546static const struct msl_timing_chart state_db[] = {
1547 { TO10, CO10, 0 },
1548 { TO10, CO40, 0, DI21A0 },
1549 { TO10, CO41, 0, DI21A0 },
1550 { TO30, CI15, 0, DI21A0 },
1551 { TO40, CO00, state_d9_TO40_CO00 },
1552 { TO50, CI33, 0, DI21A0 },
1553 { TI06, CI74, 0, DI91A0 },
1554 { TI06, CU00, 0, DI93A0 },
1555 { TI06, CU10, 0 },
1556 { TI06, CU01, 0, DI94A0 },
1557 { TI06, CU11, 0, DI95A0 },
1558 { TI06, CU12, 0 },
1559 { TI06, CU02, state_d8_TO19_CE02 },
1560 { END_OF_STATUS, 0, 0 },
1561};
1562
1563/* needs to be 1 for the per preliminary phase to continue */
1564SIG(PCOV) { return 1; }
1565
1566static uint8_t state_dc_TI06_CI70(struct ge *ge) {
1567 return !PCOV(ge) && !BIT(ge->rL2, 2) && !AITE(ge);
1568}
1569
1570static uint8_t state_dc_TI06_CU20(struct ge *ge) {
1571 return BIT(ge->rL2, 0) && !BIT(ge->ffFA, 5);
1572}
1573
1574static const struct msl_timing_chart state_dc[] = {
1575 { TO10, CO13, 0 },
1576 { TO30, CI19, 0 },
1577 { TO30, CO90, 0 },
1578 { TO40, CO01, 0 },
1579 { TO50, CI32, 0, DI22A0 },
1580 { TI06, CI70, state_dc_TI06_CI70 },
1581 { TI06, CU14, 0, DI22A0 },
1582 { TI06, CU20, state_dc_TI06_CU20 },
1583 { END_OF_STATUS, 0, 0 },
1584};
1585
1586static uint8_t state_cc_TO50_CE00(struct ge *ge) {
1587 return !ge->PUC3;
1588}
1589
1590
1591static uint8_t state_cc_TI06_CU13(struct ge *ge) {
1592 /* CU13 resets future_state bit 3. The original `|| FA00` term cleared bit 3
1593 * on a unit-busy (FA00) exit, which sent CC -> 0xd2 (an interrupt-save
1594 * state) instead of recycling to D8 to wait for the unit. Per the PER-PERI
1595 * preliminary-phase flow chart (14023130F, CPU[7] render-pg 32): when FA05
1596 * is clear and FA00 is set ("UNITA' OCCUPATA / UNIT BUSY") the sequence goes
1597 * "again back to D8". Dropping FA00 here keeps bit 3 set so CC -> 0xd8 (with
1598 * the CU11/CU04 below). The FA00=0 bootstrap path is unchanged. */
1599 return (PCOV(ge) && DU96(ge) && !DU95(ge));
1600}
1601
1602/* Unit-busy recycle: FA05 clear, FA00 set -> reset future_state bit 1 so the
1603 * CC exit lands on 0xd8 (D8) rather than 0xda. (CU04 below sets bit 4.) */
1604static uint8_t state_cc_TI06_CU11_busy(struct ge *ge) {
1605 return !BIT(ge->ffFA, 5) && BIT(ge->ffFA, 0);
1606}
1607
1608static uint8_t state_cc_TI06_CU05(struct ge *ge) {
1609 return BIT(ge->ffFA, 5) || (!BIT(ge->ffFA, 0) && DU96(ge));
1610}
1611
1612static uint8_t state_cc_TI06_CU04(struct ge *ge) {
1613 return !BIT(ge->ffFA, 5) && BIT(ge->ffFA, 0);
1614}
1615
1616static uint8_t state_cc_TI06_CI75(struct ge *ge) {
1617 return (PCOV(ge) && DU96(ge) && !DU95(ge)) || BIT(ge->ffFA, 0);
1618}
1619
1620static uint8_t state_cc_TI06_CU01(struct ge *ge) {
1621 return BIT(ge->ffFA, 5) || !BIT(ge->ffFA, 9) ;
1622}
1623
1624static const struct msl_timing_chart state_cc[] = {
1625 { TO10, CO12, 0, DI97A0 },
1626 { TO10, CO41, 0, DI97A0 },
1627 { TO25, CO30, not_AINI, ED70A0 },
1628 { TO30, CI19, 0, DI24A0 },
1629 { TO30, CO96, 0 },
1630 { TO40, CO02, DI97A0 },
1631 { TO50, CI32, AINI, 0 },
1632 { TO50, CE01, 0 },
1633 { TO50, CE00, state_cc_TO50_CE00 },
1634 /* For an EPER examine, load the real channel-1 status into RO (after the
1635 * memory read at TO50) so the DU95 no-error decode at TI06 is meaningful. */
1637 /* TODO: CI75 seems conditioned also on the type of peri operation (e.g. TPER/SPER ecc) */
1638 { TI06, CI75, state_cc_TI06_CI75 },
1639 { TI06, CU13, state_cc_TI06_CU13 },
1640 { TI06, CU12, 0 },
1641 { TI06, CU05, state_cc_TI06_CU05 },
1642 { TI06, CU04, state_cc_TI06_CU04 },
1643 { TI06, CU01, state_cc_TI06_CU01 },
1644 { TI06, CU11, state_cc_TI06_CU11_busy }, /* FA00 unit-busy -> recycle to D8 */
1645 { END_OF_STATUS, 0, 0 },
1646};
1647
1648/* Channel-2 OUTPUT data-transfer (rSI state 02/03; flow chart 14023130₁, CPU[7]
1649 * render-pg 36 "CHANNEL 2 DATA TRANSFER PHASE"). One character per RES2 cycle:
1650 * NO <- V4 (CO14); memory read RO <- mem[VO=V4] (CO30); V4 <- V4+1 (CO41/CO04);
1651 * "Load Printer Buffer" (CE16) hands RO to the integrated printer.
1652 * Reached via NA_knot (RES2 -> rSA = rSI & 0x0f = 0x02) while the printer holds
1653 * the channel-2 request; the per-character loop persists because the cycle leaves
1654 * future_state = 0x02 and the channel-2 length terminates the request. */
1655static const struct msl_timing_chart state_02[] = {
1656 { TO10, CO14, 0 }, /* NO <- V4 (channel-2 operand addresser) */
1657 { TO10, CO41, 0 }, /* counting network: V4 + 1 on NI */
1658 { TO25, CO30, 0 }, /* memory read: RO <- mem[VO = V4] */
1659 { TO40, CO04, 0 }, /* V4 <- NI (advance to next byte) */
1660 { TI06, CE16, 0 }, /* Load Printer Buffer: emit RO to channel 2 */
1661 { END_OF_STATUS, 0, 0 },
1662};
1663
1664/* Channel-2 INPUT data-transfer (rSI state 0C|0E; CPU[7] sheet 36 "CHANNEL 2
1665 * DATA TRANSFER PHASE"). One byte per RES2 cycle from the integrated reader:
1666 * VO <- V4 (CO14); V4+1 -> V4 (CO41/CO04 — card/photo reader; a magnetic
1667 * reader [PELM] would decrement); NE -> RO (CI34, the channel-2 input byte via
1668 * NE_knot when the reader-input select PIB21 is asserted); RO -> mem[VO=V4]
1669 * (CO31 WRITE, commits at TO65). Reached via NA_knot (RES2 -> rSA = rSI&0x0f =
1670 * 0x0c) while the reader holds the channel-2 request RC02; per the sheet-36
1671 * diamond a reader (PC22) byte returns to B8 to await the next request.
1672 * The page-36 RO->RI and the [~PC22] external-error arming are printer/compare
1673 * concerns (states 04|06); the bare reader read is the five commands below. */
1674static const struct msl_timing_chart state_0c[] = {
1675 { TO10, CO14, 0 }, /* VO <- V4 (channel-2 operand addresser) */
1676 { TO10, CO41, 0 }, /* counting network: NI = V4 + 1 */
1677 { TO25, CI34, 0 }, /* NE -> RO: latch the channel-2 input byte */
1678 { TO25, CO31, 0 }, /* arm memory WRITE (commits TO65: mem[VO=V4] <- RO) */
1679 { TO40, CO04, 0 }, /* V4 <- NI (advance to next byte) */
1680 { END_OF_STATUS, 0, 0 },
1681};
1682
1683/* TPER - CPER */
1684/* ----------- */
1685
1686SIG(L207) { return BIT(ge->rL2, 7); }
1687SIG(not_L207) { return !L207(ge); }
1688
1689static uint8_t state_ca_TO80_CE18(struct ge *ge) {
1690 return L207(ge) && (!BIT(ge->rL1, 7) || BIT(ge->rL1, 6) || !BIT(ge->rL1, 0));
1691}
1692
1693static const struct msl_timing_chart state_ca[] = {
1694 { TO19, CE08, L207 },
1695 { TO65, CE03, 0 },
1696 { TO80, CE18, state_ca_TO80_CE18 },
1697 { TI06, CU16, not_L207 },
1698 { TI06, CU05, 0 },
1699 { TI06, CU13, L207 },
1700 { TI06, CU11, not_L207 },
1701 { TI10, CE10, L207 },
1702 { END_OF_STATUS, 0, 0 },
1703};
1704
1705static const struct msl_timing_chart state_a8[] = {
1706 { TO10, CO12, 0, DI97A0 },
1707 { TO10, CO41, 0, DI97A0 },
1708 { TO25, CO30, not_AINI, ED70A0 },
1709 { TO30, CI19, 0, DI29A0 },
1710 { TO40, CO02, 0, DI97A0 },
1711 { TO70, CI60, 0, DI86A0 },
1712 { TO70, CI65, 0, DI86A0 },
1713 { TI05, CI05, 0, DI87A0 },
1714 { TI06, CU00, 0, DI93A0 },
1715 { END_OF_STATUS, 0, 0 },
1716};
1717
1718static const struct msl_timing_chart state_a9[] = {
1719 { TO10, CO12, 0, DI97A0 },
1720 { TO10, CO41, 0, DI97A0 },
1721 { TO25, CO30, not_AINI, ED70A0 },
1722 { TO30, CI19, 0, DI29A0 },
1723 { TO30, CI15, 0, DI84A0 },
1724 { TO30, CO97, AINI },
1725 { TO40, CO02, 0, DI97A0 },
1726 { TO50, CI32, AINI, ED75A0 },
1727 { TO70, CI62, 0, ED79A0 },
1728 { TO70, CI67, 0, ED79A0 },
1729 { TI05, CI05, 0, DI87A0 },
1730 { TI06, CI07, PC031 },
1731 { TI06, CU00, 0, DI93A0},
1732 { TI06, CU10, 0 },
1733 { TI06, CU01, DI94A0 },
1734 { END_OF_STATUS, 0, 0 },
1735};
1736
1737static const struct msl_timing_chart state_aa[] = {
1738 { TO10, CO12, 0, DI97A0 },
1739 { TO10, CO41, 0, DI97A0 },
1740 { TO25, CO30, not_AINI, ED70A0 },
1741 { TO30, CI19, 0, DI29A0 },
1742 { TO40, CO02, 0, DI97A0 },
1743 { TO70, CI60, 0, DI86A0 },
1744 { TO70, CI65, 0, DI86A0 },
1745 { TI05, CI01, 0 },
1746 { TI06, CU00, 0, DI93A0},
1747 { END_OF_STATUS, 0, 0 },
1748};
1749
1750static uint8_t state_ab_TO70_CI62(struct ge *ge) { return !(PC111(ge) && PC211(ge)); }
1751
1752static uint8_t state_ab_TO80_CE18(struct ge *ge) {
1753 /* this equation is different in the timing charts documentation (fo. 58),
1754 * and in the cpu PDS documentation (fo. 218) it seems the PDS is the right
1755 * one. */
1756 return !(PC121(ge) || PC111(ge) || PC211(ge));
1757}
1758
1759static uint8_t state_ab_TI05_CI04(struct ge *ge) { return BIT(ge->rL2, 0); }
1760static uint8_t state_ab_TI05_CI03(struct ge *ge) { return PC031(ge); }
1761
1762static const struct msl_timing_chart state_ab[] = {
1763 { TO10, CO12, 0, DI97A0 },
1764 { TO10, CO41, 0, DI97A0 },
1765 { TO19, CE07, 0 }, /* no clock in documentation! */
1766 { TO19, CE08, 0 },
1767 { TO25, CO30, not_AINI, ED70A0 },
1768 { TO30, CI19, 0, DI29A0 },
1769 { TO30, CI11, 0 },
1770 { TO40, CO02, 0, DI97A0 },
1771 { TO70, CI62, state_ab_TO70_CI62, ED79A0 },
1772 { TO70, CI67, state_ab_TO70_CI62, ED79A0 },
1773 { TO80, CE18, state_ab_TO80_CE18 },
1774 { TI05, CI01, 0 },
1775 { TI05, CI04, state_ab_TI05_CI04 },
1776 { TI05, CI03, state_ab_TI05_CI03 },
1777 { TI06, CU00, 0, DI93A0},
1778 { TI06, CU10, 0 },
1779 { TI06, CU01, 0, DI94A0},
1780 { TI06, CU11, 0, DI95A0},
1781 { TI06, CU04, 0, DI85A0},
1782 { TI10, CE10, 0 },
1783 { END_OF_STATUS, 0, 0 },
1784};
1785
1786
1787static uint8_t state_b8_TI06_CI72(struct ge *ge) { return BIT(ge->rL2, 0) && BIT(ge->rL2, 3); }
1788static uint8_t DU97_or_DU98(struct ge *ge) { return DU97(ge) || DU98(ge); }
1789static uint8_t state_b8_TI10_CE09(struct ge *ge) { return !BIT(ge->ffFA, 0) && !BIT(ge->rL2, 3) && !ge->RACI; }
1790
1791/* State b8 is the org-phase external request-wait for a channel-2 transfer.
1792 * The natural exit to alpha is gated on DU97 (= PUC2 ^ L2.3): when the channel-2
1793 * unit signals "ready/done" (PUC2), CU01/CU13/CU14/CU06 build the PER-completion
1794 * future_state and the sequencer returns to alpha with the CPU context intact.
1795 * gemu does not drive channel-2 timing at signal level, so for an integrated
1796 * printer/typewriter the printer peripheral (printer.c) asserts PUC2 (and the
1797 * CPU-active request RC00) at this wait; the completion is then performed by the
1798 * machine's own microcode here, NOT by forcing the state from outside. The
1799 * bootstrap/reader tests register no printer and never assert PUC2, so they are
1800 * unaffected. See the LPSR/TPER channel-2 flow charts (B8 -> E2|E3 via DU97). */
1801static const struct msl_timing_chart state_b8[] = {
1802 { TI06, CI72, state_b8_TI06_CI72 },
1803 { TI06, CI70, 0 },
1804 { TI06, CU01, DU97_or_DU98 },
1805 { TI06, CU13, DU97 },
1806 { TI06, CU14, DU97_or_DU98 },
1807 { TI06, CU06, DU97_or_DU98 },
1808 { TI10, CE09, state_b8_TI10_CE09 },
1809 { END_OF_STATUS, 0, 0 },
1810};
1811
1812SIG(FA01) { return BIT(ge->ffFA, 1); }
1813SIG(not_FA01) { return !FA01(ge); }
1814
1815static const struct msl_timing_chart state_b1[] = {
1816 { TO10, CO11 },
1817 { TO10, CO41 },
1818 { TO10, CO40, L205 },
1819 { TO25, CO31, FA01 },
1820 { TO30, CI15, not_FA01 },
1821 { TO30, CI12, FA01 },
1822 { TO30, CI41 },
1823 { TO40, CO01, FA01 },
1824 { TO50, CI33, FA01 },
1825 { TO80, CE18 },
1826 { TI05, CI05, not_FA01 },
1827 { TI06, CI71 },
1828 { TI06, CI81, FA01 },
1829 { TI06, CU03 },
1830 { TI06, CU10 },
1831 { END_OF_STATUS },
1832};
1833
1834
1835SIG(RIG1) { return ge->RIG1; }
1836SIG(RIG3) { return ge->RIG3; }
1837
1838/* RENIA/RILIA: channel-1 read length-count "not exhausted". The length is in L1,
1839 * decremented per character (CI15->count->CI05; CPU[7] B9 timing), and a
1840 * length-counted transfer ends at L1+1 chars (CPU[4] §5.8.4.3a) — i.e. when L1
1841 * underflows to all ones (RL1U1, ch.128).
1842 *
1843 * RENIA is the faithful terminal-count equation, gated by L204 (the order-block
1844 * "length-counted transfer" bit, rL2.4): it drops to 0 only when an actively
1845 * length-counted transfer has reached terminal. This is INERT for every read
1846 * gemu currently performs: the bootstrap/initial-load reads keep L204=0 and L1
1847 * constant at the order length (the per-character L1 decrement is not yet wired
1848 * into the b1/b9 read datapath), so they continue to end on FININ (RIG1)
1849 * byte-identically. Enabling true length termination needs that L1 decrement
1850 * wired first — tracked as the remaining datapath gap. (Equation/decode covered
1851 * by reader_signals.rl1u1_terminal_decode; inertness by the bootstrap reads.) */
1852SIG(RENIA) { return !(RL1U1(ge) && L204(ge)); }
1853SIG(RILIA) { return 1; } // 2nd-length count (decimal SS transfers) — not exercised
1854
1855SIG(RIG1A) { return !ge->RIG1; }
1856SIG(RIVE1) { return !(RIG1A(ge) && RENIA(ge) && RILIA(ge)); }
1858SIG(RIVE) { return RIVE1(ge); }
1859
1860SIG(not_L206) { return !L206(ge); }
1861
1862static uint8_t state_b9_TO25_CO31(struct ge *ge) { return !BIT(ge->ffFA, 1) && !BIT(ge->rL2, 6); }
1863static uint8_t state_b9_TO30_CI12(struct ge *ge) { return !L204(ge) && !L206(ge); }
1864
1865/* the original timingchart and the flow chart disagree, RIG1 is spelt "AIGI" in
1866 * the timings, but RIG1 in the flow, also timings use L206 and flow use L205... */
1867static uint8_t state_b9_TO40_CO01(struct ge *ge) { return (L204(ge) || (!BIT(ge->ffFA, 1) && RIG1(ge))) && !L206(ge); }
1868
1869static uint8_t state_b9_TO70_CI67(struct ge *ge) { return BIT(ge->ffFA, 1) && !L206(ge); }
1870static uint8_t state_b9_TO70_CI66(struct ge *ge) { return !BIT(ge->ffFA, 1) && !L204(ge) && !L206(ge); }
1871static uint8_t state_b9_TO80_CE05(struct ge *ge) { return !PC121(ge) && !L206(ge); }
1872static uint8_t state_b9_TI06_CU13(struct ge *ge) { return !L204(ge) && !L206(ge); }
1873static uint8_t state_b9_TI10_CE09(struct ge *ge) { return !RIVE(ge) && !PC121(ge) && !L206(ge); }
1874
1875static const struct msl_timing_chart state_b9[] = {
1876 { TO10, CO11 },
1877 { TO10, CO41 },
1878 { TO10, CO40, L205 },
1879 { TO25, CO31, state_b9_TO25_CO31 },
1880 { TO30, CI15, L204 },
1881 { TO30, CI41, L204 },
1882 { TO30, CI40, L204 },
1883 { TO30, CI12, state_b9_TO30_CI12 },
1884 { TO40, CO01, state_b9_TO40_CO01 },
1885 { TO50, CI34, not_L206 },
1886 { TO70, CI67, state_b9_TO70_CI67 },
1887 { TO70, CI66, state_b9_TO70_CI66 },
1888 { TO80, CE18, L204 },
1889 { TO80, CE05, state_b9_TO80_CE05 },
1890 { TO65, CE11, not_L206 },
1891 { TI05, CI05, L204 },
1892 { TI05, CI02, not_L206 },
1893 { TI06, CU13, state_b9_TI06_CU13 },
1894 { TI10, CE09, state_b9_TI10_CE09 },
1895 { END_OF_STATUS },
1896};
1897
1898/* Write-back condition for states ea/eb.
1899 *
1900 * The original condition read BIT(rL2,7) || PC011, but that causes a
1901 * spurious mem[V2]=0 write when the machine reaches state_ea via the
1902 * peripheral-load path (b8-WAIT → ea). During a channel-1 INPUT
1903 * (bootstrap/load) operation PC011=1 and rL2[7]=0, so the old condition
1904 * fired unconditionally and clobbered the just-loaded data.
1905 *
1906 * The write-back is only meaningful for OUTPUT transfers (rL2 bit 7 = L207
1907 * set), where the CPU had previously read memory destructively and now needs
1908 * to restore it. For INPUT transfers (peripheral → memory, L207=0) no
1909 * destructive read occurred, so no write-back is needed.
1910 *
1911 * Rename: the function used BIT(rL2,7) which is L207 (output-transfer flag),
1912 * not L206 (bit 6). Correct the name and drop the spurious PC011 term.
1913 */
1914static uint8_t L207_output_writeback(struct ge *ge) { return BIT(ge->rL2, 7); }
1915
1916static uint8_t is_jrt_or_la(struct ge *ge) { return is_jrt(ge) || is_la(ge); }
1917
1918static uint8_t state_eb_TI06_CI75(struct ge *ge) {
1919 return ((RIG3(ge) && BIT(ge->rL2, 7)) ||
1920 (RIG1(ge) && PC011(ge) && !ge->RACI));
1921}
1922
1923static uint8_t state_eb_TI06_CE19(struct ge *ge) { return 0; }
1924
1925/* EA/EB carry two physically distinct sheets -- the instruction walk on cp07
1926 * fo.34/35 and the peripheral one on fo.60/61 -- over the same two states.
1927 * They are merged here with each row carrying its own gate rather than being
1928 * selected by a dispatch table. Note DI11A0 is a pure STATE decode (SA bits
1929 * only, ch. DI11A), so the rows it gates fire on both paths; it is kept
1930 * because it is the gate the sheet prints, not because it discriminates. */
1931static uint8_t not_jrt_la(struct ge *ge) { return !is_jrt_or_la(ge); }
1932
1933/* CO18 raises the forced change-register address: unconditional on the
1934 * peripheral sheet, {SR+SL+JRT} on fo.34. LA is the one caller that must NOT
1935 * get it -- its address arrives on V2, built by the LA beta sheet. */
1936static uint8_t ea_co18(struct ge *ge) { return !is_la(ge); }
1937
1938/* The write-back is unconditional on the instruction sheet -- the register
1939 * cell is always written -- but on the peripheral sheet only OUTPUT
1940 * transfers restore the destructively-read byte. */
1941static uint8_t ea_writes_back(struct ge *ge) {
1943}
1944
1945/* Peripheral-only rows, held off the instruction path explicitly: rL2 keeps
1946 * whatever the last channel operation left in it, so gating these on the
1947 * channel state alone would let a stale L2 fire them during a JRT or LA. */
1948static uint8_t eb_peri_ce06(struct ge *ge) {
1949 return not_jrt_la(ge) && L207(ge);
1950}
1951static uint8_t eb_peri_ci75(struct ge *ge) {
1952 return not_jrt_la(ge) && state_eb_TI06_CI75(ge);
1953}
1954static uint8_t eb_peri_ce19(struct ge *ge) {
1955 return not_jrt_la(ge) && state_eb_TI06_CE19(ge);
1956}
1957
1958static const struct msl_timing_chart state_ea[] = {
1959 /* Forced address 1111 1111 = 0xFF, change register 7 {SR+SL+JRT}; the
1960 * peripheral sheet raises CO18 unconditionally, fo.34 only for JRT --
1961 * LA brings its address in on V2 instead, built by its beta sheet. */
1962 { TO10, CO18, ea_co18 },
1963 { TO10, CO97, 0, DI11A0 },
1964 { TO10, CO96, 0, DI11A0 },
1965 { TO10, CO95, 0, DI11A0 },
1966 { TO10, CO94, 0 },
1967 { TO10, CO93, 0, DI11A0 },
1968 { TO10, CO92, 0, DI11A0 },
1969 { TO10, CO91, 0 },
1970 { TO10, CO90, 0, DI11A0 },
1971 { TO10, CO12, is_la }, /* {LA}: address from V2 */
1972 { TO10, CO40, 0, DI11A0 }, /* decreasing... */
1973 { TO10, CO41, 0, DI11A0 }, /* ...count: next byte address */
1974 { TO25, CO31, ea_writes_back }, /* RO -> MEM (ED92A0) */
1975 { TO30, CI11, 0 }, /* V1 -> NO: the datum */
1976 { TO40, CO02, 0, DI11A0 }, /* NI -> V2: address-1 */
1977 { TO50, CI33, is_jrt_or_la }, /* NO21 -> RO: datum low */
1978 { TO50, CI33, not_jrt_la, DI83A0 },
1979 { TI06, CU00, 0 }, /* -> EB */
1980 { END_OF_STATUS, 0, 0 },
1981};
1982
1983
1984
1985static const struct msl_timing_chart state_eb[] = {
1986 { TO10, CO12, is_jrt_or_la }, /* V2 -> NO: the walked-down address */
1987 { TO10, CO12, not_jrt_la, DA25A0 },
1988 { TO10, CO97, 0, DI11A0 }, /* forcings as printed (no CO18: inert) */
1989 { TO10, CO96, 0, DI11A0 },
1990 { TO10, CO95, 0, DI11A0 },
1991 { TO10, CO94, 0 },
1992 { TO10, CO93, 0, DI11A0 },
1993 { TO10, CO92, 0, DI11A0 },
1994 { TO10, CO91, 0 },
1995 { TO10, CO90, 0, DI11A0 },
1996 { TO10, CO04, not_jrt_la, DI11A0 },
1997 { TO10, CO40, is_jrt_or_la },
1998 { TO10, CO41, 0, DI11A0 },
1999 { TO25, CO31, ea_writes_back }, /* RO -> MEM */
2000 { TO30, CI11, 0 },
2001 { TO40, CO02, 0, DI11A0 },
2002 { TO50, CI32, is_jrt_or_la }, /* NO43 -> RO: datum high */
2003 { TO50, CI32, not_jrt_la, DI82A0 },
2004 { TO50, CE06, eb_peri_ce06 },
2005 { TI06, CI75, eb_peri_ci75, ED91A0 },
2006 { TI06, CE19, eb_peri_ce19 },
2007 { TI06, CU00, 0 }, /* sets first */
2008 { TI06, CU13, is_jrt_or_la }, /* -> E2/E3 */
2009 { TI06, CU13, not_jrt_la, DI82A0 },
2010 { END_OF_STATUS, 0, 0 },
2011};
2012
2013/* Instruction-side EA/EB (cp07 fo.34/35, "JRT - SR - SL - LA", DA-FROM
2014 * 64+65 / 40+42): the two-byte register-cell write walk. EA writes the LOW
2015 * byte, EB the HIGH byte, V1 holds the datum (JRT: the return address; LA:
2016 * the operand EA), and the cell address comes from the forced 0xFF (= change
2017 * register 7, {SR+SL+JRT}) or from V2 built in the LA beta sheet; CO40/CO41
2018 * walk it down for the second byte. SR/SL will route here once their
2019 * executive states (cp07 fo.152-155) are transcribed. NOTE: the write goes
2020 * through the ordinary memory path, so cr_cache (a debug aid) is not synced
2021 * by JRT/LA anymore -- live addressing reads memory, as on the machine. */
2022
Bit manipulation helpers.
#define BIT(V, X)
Definition bit.h:9
static void CI73(struct ge *ge)
static void CE08(struct ge *ge)
static void CI02(struct ge *ge)
static void CI08(struct ge *ge)
static void CE01(struct ge *ge)
static void CU05(struct ge *ge)
static void CI39(struct ge *ge)
static void CO49(struct ge *ge)
static void CO04(struct ge *ge)
static void CE11(struct ge *ge)
static void CO14(struct ge *ge)
static void CE18(struct ge *ge)
static void CI21(struct ge *ge)
static void CI20(struct ge *ge)
static void CO00(struct ge *ge)
static void CU12(struct ge *ge)
static void CI00s(struct ge *ge)
static void CI66(struct ge *ge)
static void CI19(struct ge *ge)
static void CE10(struct ge *ge)
static void CI74(struct ge *ge)
static void CI17(struct ge *ge)
static void CU00(struct ge *ge)
static void CO35(struct ge *ge)
static void CI50(struct ge *ge)
static void CI15(struct ge *ge)
static void CU06(struct ge *ge)
static void CE03(struct ge *ge)
static void CI70(struct ge *ge)
static void CU07(struct ge *ge)
static void CE00(struct ge *ge)
static void CO01(struct ge *ge)
static void CI11(struct ge *ge)
static void CU02(struct ge *ge)
static void CI06(struct ge *ge)
static void CI32(struct ge *ge)
static void CI65(struct ge *ge)
static void NO_UNDRIVEN(struct ge *ge)
static void CI75(struct ge *ge)
static void CI42(struct ge *ge)
static void CU13(struct ge *ge)
static void CE07(struct ge *ge)
static void CI80(struct ge *ge)
static void CI07(struct ge *ge)
static void CI81(struct ge *ge)
static void CU17(struct ge *ge)
static void CO96(struct ge *ge)
static void CI60(struct ge *ge)
static void CI86(struct ge *ge)
static void CE06(struct ge *ge)
static void CO94(struct ge *ge)
static void CU20(struct ge *ge)
static void CO48(struct ge *ge)
static void CI68(struct ge *ge)
static void CI10(struct ge *ge)
static void CE16(struct ge *ge)
static void CO91(struct ge *ge)
static void CI05(struct ge *ge)
static void CI82(struct ge *ge)
static void CE09(struct ge *ge)
static void CI84(struct ge *ge)
static void CI72(struct ge *ge)
static void CU01(struct ge *ge)
static void CO90(struct ge *ge)
static void CE02(struct ge *ge)
static void CI46(struct ge *ge)
static void CI04(struct ge *ge)
static void INT_ACK(struct ge *ge)
static void CI88(struct ge *ge)
static void CI45(struct ge *ge)
static void CI83(struct ge *ge)
static void CI41(struct ge *ge)
static void CO18(struct ge *ge)
static void CO40(struct ge *ge)
static void CI09(struct ge *ge)
static void CI89(struct ge *ge)
static void CU10(struct ge *ge)
static void CI62(struct ge *ge)
static void CI38(struct ge *ge)
static void CI69(struct ge *ge)
static void CI03(struct ge *ge)
static void CI77(struct ge *ge)
static void CU14(struct ge *ge)
static void CO11(struct ge *ge)
static void CU16(struct ge *ge)
static void CO12(struct ge *ge)
static void NI4_ZERO(struct ge *ge)
static void CI87(struct ge *ge)
static void CI85(struct ge *ge)
static void CI44(struct ge *ge)
static void CO97(struct ge *ge)
static void CO30(struct ge *ge)
static void CI67(struct ge *ge)
static void CI40(struct ge *ge)
static void CI00(struct ge *ge)
static void CI33(struct ge *ge)
static void CO41(struct ge *ge)
static void CO92(struct ge *ge)
static void CO13(struct ge *ge)
static void CO10(struct ge *ge)
static void CO31(struct ge *ge)
static void CE05(struct ge *ge)
static void CU11(struct ge *ge)
static void EXEC_SS(struct ge *ge)
static void CI47(struct ge *ge)
static void CU03(struct ge *ge)
static void CE19(struct ge *ge)
static void CO93(struct ge *ge)
static void CI76(struct ge *ge)
static void CO95(struct ge *ge)
static void CE_chan1_status(struct ge *ge)
static void CI34(struct ge *ge)
static void CI16(struct ge *ge)
static void CI12(struct ge *ge)
static void CI78(struct ge *ge)
static void CI71(struct ge *ge)
static void CO02(struct ge *ge)
static void CU15(struct ge *ge)
static void CU04(struct ge *ge)
static void CI01(struct ge *ge)
static uint8_t state_E2_E3_TI06_CI82(struct ge *ge)
Definition msl-states.c:112
static uint8_t exec60_fetches_source(struct ge *ge)
static uint8_t jc_js1_js2_jie_lon_loll_loff_ins_ens_nop(struct ge *ge)
Definition msl-states.c:792
static uint8_t AF52_not_RO07(struct ge *ge)
static uint8_t beta_register_arithmetic(struct ge *ge)
Definition msl-states.c:762
static uint8_t not_RO06(struct ge *ge)
Definition msl-states.c:29
static uint8_t state_ab_TI05_CI04(struct ge *ge)
static uint8_t ro_byte_nonzero(struct ge *ge)
Definition msl-states.c:729
static uint8_t state_00_TO50_CI33(struct ge *ge)
static uint8_t state_cc_TI06_CU11_busy(struct ge *ge)
static uint8_t state_cc_TI06_CU04(struct ge *ge)
static uint8_t is_mvi(struct ge *ge)
Definition msl-states.c:635
static uint8_t ea_co18(struct ge *ge)
static const struct msl_timing_chart exec_50[]
static uint8_t xc_byte_nonzero(struct ge *ge)
static uint8_t state_EF_EE_TI06_CU17(struct ge *ge)
Definition msl-states.c:362
static uint8_t is_la(struct ge *ge)
Definition msl-states.c:746
static uint8_t not_cmr(struct ge *ge)
Definition msl-states.c:735
static uint8_t addr_absolute(struct ge *ge)
Definition msl-states.c:37
static uint8_t SA01_pass2(struct ge *ge)
Definition msl-states.c:740
static uint8_t cmc_done(struct ge *ge)
static uint8_t is_smr(struct ge *ge)
Definition msl-states.c:745
static uint8_t state_b9_TO40_CO01(struct ge *ge)
static uint8_t L207_output_writeback(struct ge *ge)
static uint8_t is_mvc(struct ge *ge)
Definition msl-states.c:648
static uint8_t state_dc_TI06_CI70(struct ge *ge)
static const struct msl_timing_chart state_E7[]
Definition msl-states.c:319
static uint8_t reg_result_nonzero(struct ge *ge)
static const struct msl_timing_chart state_cc[]
static uint8_t eb_peri_ce19(struct ge *ge)
static const struct msl_timing_chart exec_60[]
static const struct msl_timing_chart state_db[]
static uint8_t not_jrt_la(struct ge *ge)
static uint8_t immediate_and_mode(struct ge *ge)
Definition msl-states.c:774
static uint8_t state_80_TO30_CO97(struct ge *ge)
Definition msl-states.c:68
static const struct msl_timing_chart state_80[]
Definition msl-states.c:72
static uint8_t ins(struct ge *ge)
Definition msl-states.c:605
static const struct msl_timing_chart state_d8[]
static uint8_t LI06(struct ge *ge)
Definition msl-states.c:52
static uint8_t is_lr(struct ge *ge)
Definition msl-states.c:647
static const struct msl_timing_chart state_D3[]
Definition msl-states.c:463
static uint8_t state_ca_TO80_CE18(struct ge *ge)
static uint8_t state_c8_TI06_CI85(struct ge *ge)
static const struct msl_timing_chart state_E2_E3[]
Definition msl-states.c:120
static uint8_t state_b8_TI06_CI72(struct ge *ge)
static uint8_t SA01_pass1(struct ge *ge)
Definition msl-states.c:741
static uint8_t lon_loll(struct ge *ge)
Definition msl-states.c:598
static uint8_t is_xc(struct ge *ge)
Definition msl-states.c:650
static uint8_t state_b9_TO70_CI66(struct ge *ge)
static uint8_t is_ni(struct ge *ge)
Definition msl-states.c:636
static uint8_t not_mvq(struct ge *ge)
Definition msl-states.c:721
static uint8_t state_E4_TO70_CI60(struct ge *ge)
Definition msl-states.c:216
static uint8_t beta_register(struct ge *ge)
Definition msl-states.c:758
static uint8_t not_RO03(struct ge *ge)
Definition msl-states.c:26
static const struct msl_timing_chart state_C2[]
Definition msl-states.c:511
static uint8_t not_cmq(struct ge *ge)
Definition msl-states.c:717
static uint8_t is_amr(struct ge *ge)
Definition msl-states.c:744
static uint8_t state_eb_TI06_CE19(struct ge *ge)
static uint8_t immediate_writes_memory(struct ge *ge)
Definition msl-states.c:782
static uint8_t AF52_not_RO00(struct ge *ge)
static uint8_t beta_immediate_logic(struct ge *ge)
Definition msl-states.c:766
static uint8_t reg_carry(struct ge *ge)
static const struct msl_timing_chart state_ea[]
static uint8_t is_oc_or_nc(struct ge *ge)
Definition msl-states.c:655
static uint8_t not_RO00(struct ge *ge)
Definition msl-states.c:23
static uint8_t cmc_borrow(struct ge *ge)
static uint8_t cmc_byte_differs(struct ge *ge)
static uint8_t is_smr_or_cmr(struct ge *ge)
Definition msl-states.c:736
static const struct msl_timing_chart exec_40[]
static const struct msl_timing_chart state_E6[]
Definition msl-states.c:251
static uint8_t beta_immediate_shift(struct ge *ge)
Definition msl-states.c:770
static uint8_t is_ad_sd_cmq(struct ge *ge)
Definition msl-states.c:703
static uint8_t immediate_sets_cc(struct ge *ge)
Definition msl-states.c:783
static uint8_t state_b9_TO30_CI12(struct ge *ge)
static const struct msl_timing_chart state_0c[]
static uint8_t reg_arith50_pass1_sub(struct ge *ge)
static const struct msl_timing_chart state_D2[]
Definition msl-states.c:448
static uint8_t exec60_sets_S004(struct ge *ge)
static const struct msl_timing_chart beta_64[]
Definition msl-states.c:888
static uint8_t state_b9_TO80_CE05(struct ge *ge)
static const struct msl_timing_chart state_EF_EE[]
Definition msl-states.c:385
static uint8_t state_eb_TI06_CI75(struct ge *ge)
static const struct msl_timing_chart state_D0[]
Definition msl-states.c:480
static uint8_t state_cc_TI06_CI75(struct ge *ge)
static uint8_t AF52_not_RO05(struct ge *ge)
static const struct msl_timing_chart state_C3[]
Definition msl-states.c:532
static uint8_t urpe_set(struct ge *ge)
Definition msl-states.c:728
static uint8_t ro_digit_nonzero(struct ge *ge)
Definition msl-states.c:730
static const struct msl_timing_chart state_c8[]
static const struct msl_timing_chart state_02[]
static uint8_t pm_imm_exec(struct ge *ge)
Definition msl-states.c:641
static uint8_t is_ad_sd_cmq_mvq(struct ge *ge)
Definition msl-states.c:711
static const struct msl_timing_chart state_ca[]
static const struct msl_timing_chart state_F0[]
Definition msl-states.c:435
static uint8_t LI05(struct ge *ge)
Definition msl-states.c:51
static uint8_t state_E0_TI06_CU17(struct ge *ge)
Definition msl-states.c:148
static uint8_t beta_known_family(struct ge *ge)
Definition msl-states.c:871
static uint8_t reg_arith_pass1(struct ge *ge)
static uint8_t ss_hybrid_exit(struct ge *ge)
Definition msl-states.c:834
static uint8_t state_dc_TI06_CU20(struct ge *ge)
static uint8_t state_b8_TI10_CE09(struct ge *ge)
static const struct msl_timing_chart state_08[]
static uint8_t L1_1_ones(struct ge *ge)
Definition msl-states.c:684
static uint8_t state_E6_TO80_CI38(struct ge *ge)
Definition msl-states.c:244
static uint8_t immediate_xor_or_mode(struct ge *ge)
Definition msl-states.c:778
static const struct msl_timing_chart state_da[]
static uint8_t ss_hybrid_family(struct ge *ge)
Definition msl-states.c:823
static uint8_t state_cc_TI06_CU05(struct ge *ge)
static uint8_t is_tm(struct ge *ge)
Definition msl-states.c:640
static const struct msl_timing_chart state_aa[]
static uint8_t xc_first_pass(struct ge *ge)
static uint8_t loff(struct ge *ge)
Definition msl-states.c:617
static uint8_t FA05(struct ge *ge)
Definition msl-states.c:432
static uint8_t eb_peri_ci75(struct ge *ge)
static const struct msl_timing_chart state_E5[]
Definition msl-states.c:277
static uint8_t is_ab_sb(struct ge *ge)
Definition msl-states.c:714
static uint8_t not_RO01(struct ge *ge)
Definition msl-states.c:24
static uint8_t is_xc_or_oc(struct ge *ge)
Definition msl-states.c:658
static uint8_t beta_unclaimed(struct ge *ge)
Definition msl-states.c:876
static uint8_t is_cmr(struct ge *ge)
Definition msl-states.c:743
static uint8_t cmi_result_nonzero(struct ge *ge)
Definition msl-states.c:789
static const struct msl_timing_chart state_E0[]
Definition msl-states.c:152
static uint8_t not_RO07(struct ge *ge)
Definition msl-states.c:30
static const struct msl_timing_chart state_d9[]
static const struct msl_timing_chart state_ab[]
static uint8_t state_d9_TO40_CO00(struct ge *ge)
static uint8_t not_RO05(struct ge *ge)
Definition msl-states.c:28
static const struct msl_timing_chart state_ED_EC[]
Definition msl-states.c:366
static const struct msl_timing_chart state_C0[]
Definition msl-states.c:549
static uint8_t state_E6_TI06_CU17(struct ge *ge)
Definition msl-states.c:246
static uint8_t immediate_nonzero_cc(struct ge *ge)
Definition msl-states.c:786
static uint8_t state_b9_TI06_CU13(struct ge *ge)
static uint8_t is_cmc(struct ge *ge)
Definition msl-states.c:649
static const struct msl_timing_chart state_a9[]
static uint8_t jc_js1_js2_jie_condition_verified(struct ge *ge)
Definition msl-states.c:621
static uint8_t state_ab_TO80_CE18(struct ge *ge)
static uint8_t DU97_or_DU98(struct ge *ge)
static uint8_t AINI(struct ge *ge)
Definition msl-states.c:60
static const struct msl_timing_chart state_C1[]
Definition msl-states.c:565
static uint8_t eb_peri_ce06(struct ge *ge)
static uint8_t is_str(struct ge *ge)
Definition msl-states.c:742
static uint8_t state_cc_TI06_CU01(struct ge *ge)
static uint8_t per_peri(struct ge *ge)
Definition msl-states.c:799
static uint8_t is_ss_data_op(struct ge *ge)
Definition msl-states.c:174
static uint8_t state_d8_TO40_CO00(struct ge *ge)
static uint8_t state_ab_TI05_CI03(struct ge *ge)
static uint8_t jie(struct ge *ge)
Definition msl-states.c:609
static uint8_t is_eper_examine(struct ge *ge)
Definition msl-states.c:840
static uint8_t is_lpsr(struct ge *ge)
Definition msl-states.c:747
static uint8_t state_b9_TI10_CE09(struct ge *ge)
static uint8_t state_b9_TO25_CO31(struct ge *ge)
static uint8_t state_00_TO10_CO11(struct ge *ge)
static uint8_t state_80_TO30_CO96(struct ge *ge)
Definition msl-states.c:64
static uint8_t state_E2_E3_TI06_CU04(struct ge *ge)
Definition msl-states.c:116
static uint8_t ss_byte_loop(struct ge *ge)
static uint8_t state_ab_TO70_CI62(struct ge *ge)
static uint8_t AF52_not_RO06(struct ge *ge)
static uint8_t state_00_TO10_CO10(struct ge *ge)
static uint8_t is_sd_sb_cmq(struct ge *ge)
Definition msl-states.c:707
static uint8_t jc_js1_js2_jie(struct ge *ge)
Definition msl-states.c:588
static uint8_t beta_register_lr_str(struct ge *ge)
static uint8_t per_peri_TO25_CO30(struct ge *ge)
Definition msl-states.c:805
static uint8_t state_E2_E3_TO80_CI89(struct ge *ge)
Definition msl-states.c:99
static uint8_t is_jrt_or_la(struct ge *ge)
static uint8_t beta_co49(struct ge *ge)
Definition msl-states.c:881
static uint8_t beta_jump_control(struct ge *ge)
Definition msl-states.c:752
static uint8_t AF52_not_RO01(struct ge *ge)
static uint8_t state_cc_TI06_CU13(struct ge *ge)
static uint8_t ea_writes_back(struct ge *ge)
static uint8_t RO07(struct ge *ge)
Definition msl-states.c:217
static uint8_t AF52_not_RO02(struct ge *ge)
static uint8_t not_RO04(struct ge *ge)
Definition msl-states.c:27
static uint8_t state_d8_TO19_CE02(struct ge *ge)
static uint8_t L1_2_ones(struct ge *ge)
Definition msl-states.c:683
static const struct msl_timing_chart state_E4[]
Definition msl-states.c:219
static uint8_t AF52_not_RO04(struct ge *ge)
static uint8_t state_E7_TO80_CI38(struct ge *ge)
Definition msl-states.c:298
static uint8_t not_FA03(struct ge *ge)
Definition msl-states.c:661
static uint8_t L1_21_ones(struct ge *ge)
Definition msl-states.c:664
static uint8_t FA04(struct ge *ge)
Definition msl-states.c:431
static const struct msl_timing_chart state_00[]
static uint8_t not_str(struct ge *ge)
Definition msl-states.c:734
static const struct msl_timing_chart state_b8[]
static uint8_t nop(struct ge *ge)
Definition msl-states.c:625
static const struct msl_timing_chart state_D1[]
Definition msl-states.c:494
static const struct msl_timing_chart state_a8[]
static uint8_t is_xoc_nc(struct ge *ge)
Definition msl-states.c:651
static uint8_t ens(struct ge *ge)
Definition msl-states.c:613
static uint8_t not_RO02(struct ge *ge)
Definition msl-states.c:25
static uint8_t is_jrt(struct ge *ge)
Definition msl-states.c:629
static uint8_t is_xi(struct ge *ge)
Definition msl-states.c:639
static uint8_t is_oi(struct ge *ge)
Definition msl-states.c:637
static uint8_t FA06(struct ge *ge)
Definition msl-states.c:433
static uint8_t not_AINI(struct ge *ge)
Definition msl-states.c:61
static const struct msl_timing_chart state_b9[]
static uint8_t state_b9_TO70_CI67(struct ge *ge)
static uint8_t LI04(struct ge *ge)
Definition msl-states.c:50
static const struct msl_timing_chart state_dc[]
static uint8_t pm_reg_exec(struct ge *ge)
Definition msl-states.c:748
static uint8_t is_cmi(struct ge *ge)
Definition msl-states.c:638
static const struct msl_timing_chart state_b1[]
static uint8_t beta_algebra(struct ge *ge)
Definition msl-states.c:692
static const struct msl_timing_chart state_eb[]
static uint8_t AF52_not_RO03(struct ge *ge)
static uint8_t state_cc_TO50_CE00(struct ge *ge)
static uint8_t cmi_borrow(struct ge *ge)
Definition msl-states.c:790
#define JCC_OPCODE
Definition opcodes.h:41
#define LON_OPCODE
Definition opcodes.h:18
#define LOFF_OPCODE
Definition opcodes.h:15
#define SP_OPCODE
Definition opcodes.h:75
#define ENS_OPCODE
Definition opcodes.h:9
#define AB_OPCODE
Definition opcodes.h:84
#define LPSR_OPCODE
Definition opcodes.h:50
#define XC_OPCODE
Definition opcodes.h:65
#define NC_OPCODE
Definition opcodes.h:62
#define SD_OPCODE
Definition opcodes.h:83
#define LOFF_2NDCHAR
Definition opcodes.h:16
#define SL_OPCODE
Definition opcodes.h:69
#define CMP_OPCODE
Definition opcodes.h:73
#define MP_OPCODE
Definition opcodes.h:76
#define PERI_OPCODE
Definition opcodes.h:49
#define LON_2NDCHAR
Definition opcodes.h:19
#define CMC_OPCODE
Definition opcodes.h:63
#define UPK_OPCODE
Definition opcodes.h:66
#define NI_OPCODE
Definition opcodes.h:45
#define JS1_2NDCHAR
Definition opcodes.h:36
#define INS_OPCODE
Definition opcodes.h:12
#define INS_2NDCHAR
Definition opcodes.h:13
#define PKS_OPCODE
Definition opcodes.h:78
#define STR_OPCODE
Definition opcodes.h:53
#define AD_OPCODE
Definition opcodes.h:82
#define JRT_OPCODE
Definition opcodes.h:38
#define OC_OPCODE
Definition opcodes.h:64
#define DP_OPCODE
Definition opcodes.h:77
#define SB_OPCODE
Definition opcodes.h:85
#define OI_OPCODE
Definition opcodes.h:47
#define HLT_OPCODE
Definition opcodes.h:25
#define JIE_OPCODE
Definition opcodes.h:29
#define XI_OPCODE
Definition opcodes.h:48
#define LR_OPCODE
Definition opcodes.h:54
#define JC_OPCODE
Definition opcodes.h:39
#define PER_OPCODE
Definition opcodes.h:51
#define CMI_OPCODE
Definition opcodes.h:46
#define MVC_OPCODE
Definition opcodes.h:61
#define AP_OPCODE
Definition opcodes.h:74
#define JS2_OPCODE
Definition opcodes.h:32
#define EDT_OPCODE
Definition opcodes.h:71
#define MVI_OPCODE
Definition opcodes.h:44
#define SMR_OPCODE
Definition opcodes.h:57
#define PK_OPCODE
Definition opcodes.h:68
#define NOP2_OPCODE
Definition opcodes.h:24
#define JU_OPCODE
Definition opcodes.h:40
#define SR_OPCODE
Definition opcodes.h:67
#define MVQ_OPCODE
Definition opcodes.h:80
#define MVP_OPCODE
Definition opcodes.h:72
#define LOLL_OPCODE
Definition opcodes.h:21
#define JS1_OPCODE
Definition opcodes.h:35
#define AMR_OPCODE
Definition opcodes.h:56
#define LA_OPCODE
Definition opcodes.h:42
#define CMQ_OPCODE
Definition opcodes.h:81
#define ENS_2NDCHAR
Definition opcodes.h:10
#define TR_OPCODE
Definition opcodes.h:70
#define JS2_2NDCHAR
Definition opcodes.h:33
#define RDC_OPCODE
Definition opcodes.h:52
#define CMR_OPCODE
Definition opcodes.h:55
#define TM_OPCODE
Definition opcodes.h:43
#define JIE_2NDCHAR
Definition opcodes.h:30
#define UPKS_OPCODE
Definition opcodes.h:79
Signals.
#define SIG(name)
Definition signals.h:17
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:172
uint8_t RINT
Definition ge.h:493
uint8_t ALOI
Load connector selection.
Definition ge.h:384
uint8_t AINI
Program Loading.
Definition ge.h:377
uint8_t ffFA
Special conditions register 2.
Definition ge.h:352
uint16_t rRO
Multipurpose 8+1 bit register.
Definition ge.h:248
struct ge_console_switches console_switches
The current state of the console switches.
Definition ge.h:685
uint8_t PUC3
Channel 3 in transfer.
Definition ge.h:547
uint8_t rL2
Auxiliary register.
Definition ge.h:232
uint8_t ASIN
STEP-BY-STEP, the OPERATOR panel switch (signal ASIN).
Definition ge.h:477
uint8_t AVER
Jump Condition Verified.
Definition ge.h:442
uint8_t RACI
Rejected Command.
Definition ge.h:661
uint16_t rL1
Length of the operand.
Definition ge.h:231
uint8_t rSA
Future state configuration.
Definition ge.h:331
uint8_t ADIR
Disable Step By Step.
Definition ge.h:456
uint8_t RIG1
End from controller 1.
Definition ge.h:656
uint8_t rUA
UA (arithmetic unit) output latch.
Definition ge.h:260
uint8_t RIG3
Definition ge.h:658
uint8_t URPE
Definition ge.h:554
uint8_t rFO
Current function code.
Definition ge.h:284
Timing chart row.
Definition msl-timings.h:16