root/src/dps8/doAppendCycleOperandRead.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. doAppendCycleOperandRead_

   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 3b4b8be2-171d-11ee-84fd-80ee73e9b8e7
   5  *
   6  * ---------------------------------------------------------------------------
   7  *
   8  * Copyright (c) 2022-2023 Charles Anthony
   9  * Copyright (c) 2022-2023 Jeffrey H. Johnson
  10  * Copyright (c) 2022-2025 The DPS8M Development Team
  11  *
  12  * This software is made available under the terms of the ICU License.
  13  * See the LICENSE.md file at the top-level directory of this distribution.
  14  *
  15  * ---------------------------------------------------------------------------
  16  */
  17 
  18 //
  19 //        A:   fetch sdw
  20 //        B:   check RB consistency
  21 //        B1:  Is CALL6? Yes---------------------------------------+
  22 //               No                                                |
  23 //             Is transfer? Yes---------------+                E: Check RB
  24 //               No                           |                    |
  25 //             Check Read RB             F: Check Execute RB       |
  26 //                |                      D: Check RALR             |
  27 //                |                           |                    |
  28 //                +<--------------------------+<-------------------+
  29 //                |
  30 //                V
  31 //        G:   Check bound
  32 //             Paged? No----------------------+
  33 //               Yes                          |
  34 //             Fetch PTW                      |
  35 //        I:   Compute final address     H:   Compute Final Address
  36 //                |                           |
  37 //                +<--------------------------+
  38 //                |
  39 //                V
  40 //        HI:  Read operand
  41 //             CALL6? Yes--------------------------------------+
  42 //               No                                            |
  43 //             Transfer? Yes -----------------+                |
  44 //               No                           |                |
  45 //                |                           |                |
  46 //                |                      L:  Handle TSPn   N: Handle CALL6
  47 //                |                      KL: Set IC           Set IC
  48 //                |                           |                |
  49 //                |                           +<---------------+
  50 //                |                           |
  51 //                |                      M: Set P
  52 //                |                           |
  53 //                +<--------------------------+
  54 //                |
  55 //                V
  56 //              Exit
  57 
  58 // Compiled twice (see FULL_MODEL_ON and dps8_append.c)
  59 static ALWAYS_INLINE word24 doAppendCycleOperandRead_ (cpu_state_t * cpup, word36 * data, uint nWords, const bool full) {
     /* [previous][next][first][last][top][bottom][index][help] */
  60 static int evcnt = 0;
  61   DCDstruct * i = & cpu.currentInstruction;
  62   (void)evcnt;
  63   DBGAPP ("doAppendCycleOperandRead(Entry) thisCycle=OPERAND_READ\r\n");
  64   DBGAPP ("doAppendCycleOperandRead(Entry) lastCycle=%s\r\n", str_pct (cpu.apu.lastCycle));
  65   DBGAPP ("doAppendCycleOperandRead(Entry) CA %06o\r\n", cpu.TPR.CA);
  66   DBGAPP ("doAppendCycleOperandRead(Entry) n=%2u\r\n", nWords);
  67   DBGAPP ("doAppendCycleOperandRead(Entry) PPR.PRR=%o PPR.PSR=%05o\r\n", cpu.PPR.PRR, cpu.PPR.PSR);
  68   DBGAPP ("doAppendCycleOperandRead(Entry) TPR.TRR=%o TPR.TSR=%05o\r\n", cpu.TPR.TRR, cpu.TPR.TSR);
  69 
  70   if (i->b29) {
  71     DBGAPP ("doAppendCycleOperandRead(Entry) isb29 PRNO %o\r\n", GET_PRN (IWB_IRODD));
  72   }
  73 
  74   uint this = UC_OPERAND_READ;
  75   if (i->info->flags & TRANSFER_INS)
  76     this = UC_OPERAND_READ_TRA;
  77   if (i->info->flags & CALL6_INS)
  78     this = UC_OPERAND_READ_CALL6;
  79 
  80   word24 finalAddress = 0;
  81   word24 pageAddress = 0;
  82   word3 RSDWH_R1 = 0;
  83   word14 bound = 0;
  84   word1 p = 0;
  85   bool paged;
  86 
  87 // Is this cycle a candidate for ucache?
  88 
  89 //#define TEST_UCACHE
  90 #if defined(TEST_UCACHE)
  91   bool cacheHit;
  92   cacheHit = false; // Assume skip...
  93 #endif /* if defined(TEST_UCACHE) */
  94 
  95 
  96   // Is OPCODE call6?
  97 
  98   // See E1; The TRR needs to be checked and set to R2; this will vary across different
  99   // CALL6 calls.
 100   if (i->info->flags & CALL6_INS) {
 101 # if defined(UCACHE_STATS)
 102     cpu.uCache.call6Skips ++;
 103 # endif /* if defined(UCACHE_STATS) */
 104     goto skip;
 105   }
 106 
 107 
 108 
 109 
 110 
 111 
 112 
 113 
 114 
 115 
 116   // Transfer?
 117   if (i->info->flags & TRANSFER_INS) {
 118     // check ring alarm to catch outbound transfers
 119     if (cpu.rRALR && (cpu.PPR.PRR >= cpu.rRALR)) {
 120 #if defined(UCACHE_STATS)
 121       cpu.uCache.ralrSkips ++;
 122 #endif /* if defined(UCACHE_STATS) */
 123       goto skip;
 124     }
 125   }
 126 
 127 // Yes; check the ucache
 128 
 129 #if defined(TEST_UCACHE)
 130   word24 cachedAddress;
 131   word3 cachedR1;
 132   word14 cachedBound;
 133   word1 cachedP;
 134   bool cachedPaged;
 135   cacheHit =
 136       ucCacheCheck (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, & cachedBound, & cachedP, & cachedAddress, & cachedR1, & cachedPaged);
 137 # if defined(HDBG)
 138   hdbgNote ("doAppendCycleOperandRead.h", "test cache check %s %d %u %05o:%06o %05o %o %08o %o %o",
 139             cacheHit ? "hit" : "miss", evcnt, this, cpu.TPR.TSR, cpu.TPR.CA, cachedBound,
 140             cachedP, cachedAddress, cachedR1, cachedPaged);
 141 # endif /* if defined(HDBG) */
 142   goto miss;
 143 #else
 144   if (! ucCacheCheck (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, & bound, & p, & pageAddress, & RSDWH_R1, & paged)) {
 145 # if defined(HDBG)
 146     hdbgNote ("doAppendCycleOperandRead.h", "miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 147 # endif /* if defined(HDBG) */
 148     goto miss;
 149   }
 150 #endif /* if defined(TEST_UCACHE) */
 151 
 152   if (paged) {
 153     finalAddress = pageAddress + (cpu.TPR.CA & OS18MASK);
 154   } else {
 155     finalAddress = pageAddress + cpu.TPR.CA;
 156   }
 157   cpu.RSDWH_R1 = RSDWH_R1;
 158 
 159 // ucache hit; housekeeping...
 160   //sim_printf ("hit  %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 161 #if defined(HDBG)
 162   hdbgNote ("doAppendCycleOperandRead.h", "hit  %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 163 #endif /* if defined(HDBG) */
 164 
 165   // the APU status of the cycle, as the miss path sets it (PA865 03A)
 166   if (full)   // (3), see FULL_MODEL_ON
 167     set_apu_status (cpup, paged ? apuStatus_FAP : apuStatus_FANP);
 168   cpu.apu.lastCycle = OPERAND_READ;
 169   goto HI;
 170 
 171 
 172 skip:;
 173   //sim_printf ("miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 174 # if defined(HDBG)
 175   hdbgNote ("doAppendCycleOperandRead.h", "skip %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 176 # endif /* if defined(HDBG) */
 177 # if defined(UCACHE_STATS)
 178   cpu.uCache.skips[this] ++;
 179 # endif /* if defined(UCACHE_STATS) */
 180 
 181 
 182 miss:;
 183 
 184   bool nomatch = true;
 185   if (cpu.tweaks.enable_wam) {
 186     // AL39: The associative memory is ignored (forced to "no match") during
 187     // address preparation.
 188     // lptp,lptr,lsdp,lsdr,sptp,sptr,ssdp,ssdr
 189     // Unfortunately, ISOLTS doesn't try to execute any of these in append mode.
 190     // XXX should this be only for OPERAND_READ and OPERAND_STORE?
 191     nomatch = ((i->opcode == 0232 || i->opcode == 0254 ||
 192                 i->opcode == 0154 || i->opcode == 0173) &&
 193                 i->opcodeX ) ||
 194                ((i->opcode == 0557 || i->opcode == 0257) &&
 195                 ! i->opcodeX);
 196   }
 197 
 198   processor_cycle_type lastCycle = cpu.apu.lastCycle;
 199   cpu.apu.lastCycle = OPERAND_READ;
 200 
 201   DBGAPP ("doAppendCycleOperandRead(Entry) XSF %o\r\n", cpu.cu.XSF);
 202 
 203   PNL (L68_ (cpu.apu.state = 0;))
 204 
 205   cpu.RSDWH_R1 = 0;
 206 
 207   cpu.acvFaults = 0;
 208 
 209 //#define FMSG(x) x
 210 #define FMSG(x)
 211   FMSG (char * acvFaultsMsg = "<unknown>";)
 212 
 213 ////////////////////////////////////////
 214 //
 215 // Sheet 1: "START APPEND"
 216 //
 217 ////////////////////////////////////////
 218 
 219 // START APPEND
 220   word3 n = 0; // PRn to be saved to TSN_PRNO
 221 
 222 ////////////////////////////////////////
 223 //
 224 // Sheet 2: "A"
 225 //
 226 ////////////////////////////////////////
 227 
 228 //
 229 //  A:
 230 //    Get SDW
 231 
 232   //PNL (cpu.APUMemAddr = address;)
 233   PNL (cpu.APUMemAddr = cpu.TPR.CA;)
 234 
 235   DBGAPP ("doAppendCycleOperandRead(A)\r\n");
 236 
 237   // is SDW for C(TPR.TSR) in SDWAM?
 238   if (nomatch || ! fetch_sdw_from_sdwam (cpup, cpu.TPR.TSR)) {
 239     // No
 240     DBGAPP ("doAppendCycleOperandRead(A):SDW for segment %05o not in SDWAM\r\n", cpu.TPR.TSR);
 241     DBGAPP ("doAppendCycleOperandRead(A):DSBR.U=%o\r\n", cpu.DSBR.U);
 242 
 243     if (cpu.DSBR.U == 0) {
 244       fetch_dsptw (cpup, cpu.TPR.TSR);
 245 
 246       if (! cpu.PTW0.DF)
 247         doFault (FAULT_DF0 + cpu.PTW0.FC, fst_zero, "doAppendCycleOperandRead(A): PTW0.F == 0");
 248 
 249       if (! cpu.PTW0.U)
 250         modify_dsptw (cpup, cpu.TPR.TSR);
 251 
 252       fetch_psdw (cpup, cpu.TPR.TSR);
 253     } else
 254       fetch_nsdw (cpup, cpu.TPR.TSR); // load SDW0 from descriptor segment table.
 255 
 256     if (cpu.SDW0.DF == 0) {
 257       DBGAPP ("doAppendCycleOperandRead(A): SDW0.F == 0! " "Initiating directed fault\r\n");
 258       // initiate a directed fault ...
 259       doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
 260     }
 261     // load SDWAM .....
 262     load_sdwam (cpup, cpu.TPR.TSR, nomatch);
 263   }
 264   DBGAPP ("doAppendCycleOperandRead(A) R1 %o R2 %o R3 %o E %o\r\n", cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.SDW->E);
 265 
 266   // Yes...
 267   RSDWH_R1 = cpu.RSDWH_R1 = cpu.SDW->R1;
 268 
 269 ////////////////////////////////////////
 270 //
 271 // Sheet 3: "B"
 272 //
 273 ////////////////////////////////////////
 274 
 275 //
 276 // B: Check the ring
 277 //
 278 
 279   DBGAPP ("doAppendCycleOperandRead(B)\r\n");
 280 
 281   // check ring bracket consistency
 282 
 283   //C(SDW.R1) <= C(SDW.R2) <= C(SDW .R3)?
 284   if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3)) {
 285     // Set fault ACV0 = IRO
 286     cpu.acvFaults |= ACV0;
 287     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 288     FMSG (acvFaultsMsg = "acvFaults(B) C(SDW.R1) <= C(SDW.R2) <= " "C(SDW .R3)";)
 289   }
 290 
 291   // lastCycle == RTCD_OPERAND_FETCH
 292   // if a fault happens between the RTCD_OPERAND_FETCH and the INSTRUCTION_FETCH
 293   // of the next instruction - this happens about 35 time for just booting  and
 294   // shutting down multics -- a stored lastCycle is useless.
 295   // the opcode is preserved across faults and only replaced as the
 296   // INSTRUCTION_FETCH succeeds.
 297   if (lastCycle == RTCD_OPERAND_FETCH)
 298     sim_warn ("%s: lastCycle == RTCD_OPERAND_FETCH opcode %0#o\r\n", __func__, i->opcode);
 299 
 300   //
 301   // B1: The operand is one of: an instruction, data to be read or data to be
 302   //     written
 303   //
 304 
 305   // Is OPCODE call6?
 306   if (i->info->flags & CALL6_INS)
 307     goto E;
 308 
 309   // Transfer
 310   if (i->info->flags & TRANSFER_INS)
 311     goto F;
 312 
 313   //
 314   // check read bracket for read access
 315   //
 316 
 317   DBGAPP ("doAppendCycleOperandRead(B):!STR-OP\r\n");
 318 
 319   // No
 320   // C(TPR.TRR) > C(SDW .R2)?
 321   if (cpu.TPR.TRR > cpu.SDW->R2) {
 322     DBGAPP ("ACV3\r\n");
 323     DBGAPP ("doAppendCycleOperandRead(B) ACV3\r\n");
 324     //Set fault ACV3 = ORB
 325     cpu.acvFaults |= ACV3;
 326     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 327     FMSG (acvFaultsMsg = "acvFaults(B) C(TPR.TRR) > C(SDW .R2)";)
 328   }
 329 
 330   if (cpu.SDW->R == 0) {
 331     // isolts 870
 332     cpu.TPR.TRR = cpu.PPR.PRR;
 333 
 334     //C(PPR.PSR) = C(TPR.TSR)?
 335     if (cpu.PPR.PSR != cpu.TPR.TSR) {
 336       DBGAPP ("ACV4\r\n");
 337       DBGAPP ("doAppendCycleOperandRead(B) ACV4\r\n");
 338       //Set fault ACV4 = R-OFF
 339       cpu.acvFaults |= ACV4;
 340       PNL (L68_ (cpu.apu.state |= apu_FLT;))
 341       FMSG (acvFaultsMsg = "acvFaults(B) C(PPR.PSR) = C(TPR.TSR)";)
 342     //} else {
 343       // sim_warn ("doAppendCycleOperandRead(B) SDW->R == 0 && cpu.PPR.PSR == cpu.TPR.TSR: %0#o\r\n", cpu.PPR.PSR);
 344     }
 345   }
 346 
 347   goto G;
 348 
 349 ////////////////////////////////////////
 350 //
 351 // Sheet 4: "C" "D"
 352 //
 353 ////////////////////////////////////////
 354 
 355 D:;
 356   DBGAPP ("doAppendCycleOperandRead(D)\r\n");
 357 
 358   // transfer or instruction fetch
 359 
 360   // check ring alarm to catch outbound transfers
 361 
 362   if (cpu.rRALR == 0)
 363     goto G;
 364 
 365   // C(PPR.PRR) < RALR?
 366   if (! (cpu.PPR.PRR < cpu.rRALR)) {
 367     DBGAPP ("ACV13\r\n");
 368     DBGAPP ("acvFaults(D) C(PPR.PRR) %o < RALR %o\r\n", cpu.PPR.PRR, cpu.rRALR);
 369     cpu.acvFaults |= ACV13;
 370     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 371     FMSG (acvFaultsMsg = "acvFaults(D) C(PPR.PRR) < RALR";)
 372   }
 373 
 374   goto G;
 375 
 376 ////////////////////////////////////////
 377 //
 378 // Sheet 5: "E"
 379 //
 380 ////////////////////////////////////////
 381 
 382 E:;
 383 
 384   //
 385   // check ring bracket for instruction fetch after call6 instruction
 386   //   (this is the call6 read operand)
 387   //
 388 
 389   DBGAPP ("doAppendCycleOperandRead(E): CALL6\r\n");
 390   DBGAPP ("doAppendCycleOperandRead(E): E %o G %o PSR %05o TSR %05o CA %06o " "EB %06o R %o%o%o TRR %o PRR %o\r\n",
 391           cpu.SDW->E,  cpu.SDW->G,  cpu.PPR.PSR, cpu.TPR.TSR, cpu.TPR.CA, cpu.SDW->EB,
 392           cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.TPR.TRR, cpu.PPR.PRR);
 393 
 394   //SDW.E set ON?
 395   if (! cpu.SDW->E) {
 396     DBGAPP ("ACV2 b\r\n");
 397     DBGAPP ("doAppendCycleOperandRead(E) ACV2\r\n");
 398     // Set fault ACV2 = E-OFF
 399     cpu.acvFaults |= ACV2;
 400     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 401     FMSG (acvFaultsMsg = "acvFaults(E) SDW .E set OFF";)
 402   }
 403 
 404   //SDW .G set ON?
 405   if (cpu.SDW->G)
 406     goto E1;
 407 
 408   // C(PPR.PSR) = C(TPR.TSR)?
 409   if (cpu.PPR.PSR == cpu.TPR.TSR && ! TST_I_ABS)
 410     goto E1;
 411 
 412   // XXX This doesn't seem right
 413   // EB is word 15; masking address makes no sense; rather 0-extend EB
 414   // Fixes ISOLTS 880-01
 415   if (cpu.TPR.CA >= (word18) cpu.SDW->EB) {
 416     DBGAPP ("ACV7\r\n");
 417     DBGAPP ("doAppendCycleOperandRead(E) ACV7\r\n");
 418     // Set fault ACV7 = NO GA
 419     cpu.acvFaults |= ACV7;
 420     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 421     FMSG (acvFaultsMsg = "acvFaults(E) TPR.CA4-17 >= SDW.CL";)
 422   }
 423 
 424 E1:
 425   DBGAPP ("doAppendCycleOperandRead(E1): CALL6 (cont'd)\r\n");
 426 
 427   // C(TPR.TRR) > SDW.R3?
 428   if (cpu.TPR.TRR > cpu.SDW->R3) {
 429     DBGAPP ("ACV8\r\n");
 430     DBGAPP ("doAppendCycleOperandRead(E) ACV8\r\n");
 431     //Set fault ACV8 = OCB
 432     cpu.acvFaults |= ACV8;
 433     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 434     FMSG (acvFaultsMsg = "acvFaults(E1) C(TPR.TRR) > SDW.R3";)
 435   }
 436 
 437   // C(TPR.TRR) < SDW.R1?
 438   if (cpu.TPR.TRR < cpu.SDW->R1) {
 439     DBGAPP ("ACV9\r\n");
 440     DBGAPP ("doAppendCycleOperandRead(E) ACV9\r\n");
 441     // Set fault ACV9 = OCALL
 442     cpu.acvFaults |= ACV9;
 443     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 444     FMSG (acvFaultsMsg = "acvFaults(E1) C(TPR.TRR) < SDW.R1";)
 445   }
 446 
 447   // C(TPR.TRR) > C(PPR.PRR)?
 448   if (cpu.TPR.TRR > cpu.PPR.PRR) {
 449     // C(PPR.PRR) < SDW.R2?
 450     if (cpu.PPR.PRR < cpu.SDW->R2) {
 451       DBGAPP ("ACV10\r\n");
 452       DBGAPP ("doAppendCycleOperandRead(E) ACV10\r\n");
 453       // Set fault ACV10 = BOC
 454       cpu.acvFaults |= ACV10;
 455       PNL (L68_ (cpu.apu.state |= apu_FLT;))
 456       FMSG (acvFaultsMsg = "acvFaults(E1) C(TPR.TRR) > C(PPR.PRR) && " "C(PPR.PRR) < SDW.R2";)
 457     }
 458   }
 459 
 460   DBGAPP ("doAppendCycleOperandRead(E1): CALL6 TPR.TRR %o SDW->R2 %o\r\n", cpu.TPR.TRR, cpu.SDW->R2);
 461 
 462   // C(TPR.TRR) > SDW.R2?
 463   if (cpu.TPR.TRR > cpu.SDW->R2) {
 464     // SDW.R2 -> C(TPR.TRR)
 465     cpu.TPR.TRR = cpu.SDW->R2;
 466   }
 467 
 468   DBGAPP ("doAppendCycleOperandRead(E1): CALL6 TPR.TRR %o\r\n", cpu.TPR.TRR);
 469 
 470   goto G;
 471 
 472 ////////////////////////////////////////
 473 //
 474 // Sheet 6: "F"
 475 //
 476 ////////////////////////////////////////
 477 
 478 F:;
 479   PNL (L68_ (cpu.apu.state |= apu_PIAU;))
 480   DBGAPP ("doAppendCycleOperandRead(F): transfer or instruction fetch\r\n");
 481 
 482   //
 483   // check ring bracket for instruction fetch
 484   //
 485 
 486   // C(TPR.TRR) < C(SDW .R1)?
 487   // C(TPR.TRR) > C(SDW .R2)?
 488   if (cpu.TPR.TRR < cpu.SDW->R1 || cpu.TPR.TRR > cpu.SDW->R2) {
 489     DBGAPP ("ACV1 a/b\r\n");
 490     DBGAPP ("acvFaults(F) ACV1 !( C(SDW .R1) %o <= C(TPR.TRR) %o <= C(SDW .R2) %o )\r\n", cpu.SDW->R1, cpu.TPR.TRR, cpu.SDW->R2);
 491     cpu.acvFaults |= ACV1;
 492     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 493     FMSG (acvFaultsMsg = "acvFaults(F) C(TPR.TRR) < C(SDW .R1)";)
 494   }
 495   // SDW .E set ON?
 496   if (! cpu.SDW->E) {
 497     DBGAPP ("ACV2 c\r\n");
 498     DBGAPP ("doAppendCycleOperandRead(F) ACV2\r\n");
 499     cpu.acvFaults |= ACV2;
 500     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 501     FMSG (acvFaultsMsg = "acvFaults(F) SDW .E set OFF";)
 502   }
 503 
 504   // C(PPR.PRR) = C(TPR.TRR)?
 505   if (cpu.PPR.PRR != cpu.TPR.TRR) {
 506     DBGAPP ("ACV12\r\n");
 507     DBGAPP ("doAppendCycleOperandRead(F) ACV12\r\n");
 508     //Set fault ACV12 = CRT
 509     cpu.acvFaults |= ACV12;
 510     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 511     FMSG (acvFaultsMsg = "acvFaults(F) C(PPR.PRR) != C(TPR.TRR)";)
 512   }
 513 
 514   goto D;
 515 
 516 ////////////////////////////////////////
 517 //
 518 // Sheet 7: "G"
 519 //
 520 ////////////////////////////////////////
 521 
 522 G:;
 523 
 524   DBGAPP ("doAppendCycleOperandRead(G)\r\n");
 525 
 526   //C(TPR.CA)0,13 > SDW.BOUND?
 527   if (((cpu.TPR.CA >> 4) & 037777) > cpu.SDW->BOUND) {
 528     DBGAPP ("ACV15\r\n");
 529     DBGAPP ("doAppendCycleOperandRead(G) ACV15\r\n");
 530     cpu.acvFaults |= ACV15;
 531     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 532     FMSG (acvFaultsMsg = "acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND";)
 533     DBGAPP ("acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND\r\n" "   CA %06o CA>>4 & 037777 %06o SDW->BOUND %06o",
 534             cpu.TPR.CA, ((cpu.TPR.CA >> 4) & 037777), cpu.SDW->BOUND);
 535   }
 536   bound = cpu.SDW->BOUND;
 537   p = cpu.SDW->P;
 538 
 539   if (cpu.acvFaults) {
 540     DBGAPP ("doAppendCycleOperandRead(G) acvFaults\r\n");
 541     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 542     // Initiate an access violation fault
 543     doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults},
 544             "ACV fault");
 545   }
 546 
 547   // is segment C(TPR.TSR) paged?
 548   if (cpu.SDW->U)
 549     goto H; // Not paged
 550 
 551   // Yes. segment is paged ...
 552   // is PTW for C(TPR.CA) in PTWAM?
 553 
 554   DBGAPP ("doAppendCycleOperandRead(G) CA %06o\r\n", cpu.TPR.CA);
 555   if (nomatch ||
 556       ! fetch_ptw_from_ptwam (cpup, cpu.SDW->POINTER, cpu.TPR.CA)) {
 557     fetch_ptw (cpup, cpu.SDW, cpu.TPR.CA);
 558     if (! cpu.PTW0.DF) {
 559       // initiate a directed fault
 560       doFault (FAULT_DF0 + cpu.PTW0.FC, (_fault_subtype) {.bits=0},
 561               "PTW0.F == 0");
 562     }
 563     loadPTWAM (cpup, cpu.SDW->POINTER, cpu.TPR.CA, nomatch); // load PTW0 to PTWAM
 564   }
 565 
 566   // Prepage mode?
 567   // check for "uninterruptible" EIS instruction
 568   // ISOLTS-878 02: mvn,cmpn,mvne,ad3d; obviously also
 569   // ad2/3d,sb2/3d,mp2/3d,dv2/3d
 570   // DH03 p.8-13: probably also mve,btd,dtb
 571   if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
 572       || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
 573     do_ptw2 (cpup, cpu.SDW, cpu.TPR.CA);
 574   }
 575   goto I;
 576 
 577 ////////////////////////////////////////
 578 //
 579 // Sheet 8: "H", "I"
 580 //
 581 ////////////////////////////////////////
 582 
 583 H:;
 584   DBGAPP ("doAppendCycleOperandRead(H): FANP\r\n");
 585 
 586   paged = false;
 587 
 588   PNL (L68_ (cpu.apu.state |= apu_FANP;))
 589 
 590 
 591 
 592 
 593 
 594 
 595 
 596   set_apu_status (cpup, apuStatus_FANP);
 597 #if defined(HDBG)
 598   hdbgNote ("doAppendCycleOperandRead", "FANP");
 599 #endif /* if defined(HDBG) */
 600   DBGAPP ("doAppendCycleOperandRead(H): SDW->ADDR=%08o CA=%06o\r\n",
 601           cpu.SDW->ADDR, cpu.TPR.CA);
 602 
 603   pageAddress = (cpu.SDW->ADDR & 077777760);
 604   finalAddress = (cpu.SDW->ADDR & 077777760) + cpu.TPR.CA;
 605   finalAddress &= 0xffffff;
 606   PNL (cpu.APUMemAddr = finalAddress;)
 607 
 608   DBGAPP ("doAppendCycleOperandRead(H:FANP): (%05o:%06o) finalAddress=%08o\r\n",
 609           cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
 610 
 611   goto HI;
 612 
 613 I:;
 614 
 615 // Set PTW.M
 616 
 617   DBGAPP ("doAppendCycleOperandRead(I): FAP\r\n");
 618 
 619   paged = true;
 620 
 621 #if defined(HDBG)
 622   hdbgNote ("doAppendCycleOperandRead", "FAP");
 623 #endif /* if defined(HDBG) */
 624   // final address paged
 625   set_apu_status (cpup, apuStatus_FAP);
 626   PNL (L68_ (cpu.apu.state |= apu_FAP;))
 627 
 628   word24 y2 = cpu.TPR.CA % 1024;
 629 
 630   pageAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6);
 631   // AL39: The hardware ignores low order bits of the main memory page
 632   // address according to page size
 633   finalAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6) + y2;
 634   finalAddress &= 0xffffff;
 635   PNL (cpu.APUMemAddr = finalAddress;)
 636 
 637   L68_ (
 638     if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
 639       add_l68_APU_history (cpup, APUH_FAP);
 640   )
 641 
 642   DBGAPP ("doAppendCycleOperandRead(H:FAP): (%05o:%06o) finalAddress=%08o\r\n",
 643           cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
 644 
 645   //goto HI;
 646 
 647 HI:
 648   DBGAPP ("doAppendCycleOperandRead(HI)\r\n");
 649 
 650 #if defined(TEST_UCACHE)
 651   if (cacheHit) {
 652     bool err = false;
 653     if (cachedAddress != pageAddress) {
 654      sim_printf ("cachedAddress %08o != pageAddress %08o\r\n",
 655              cachedAddress, pageAddress);
 656      err = true;
 657     }
 658     if (cachedR1 != RSDWH_R1) {
 659       sim_printf ("cachedR1 %01o != RSDWH_R1 %01o\r\n",
 660               cachedR1, RSDWH_R1);
 661       err = true;
 662     }
 663     if (cachedBound != bound) {
 664       sim_printf ("cachedBound %01o != bound %01o\r\n",
 665               cachedBound, bound);
 666       err = true;
 667     }
 668     if (cachedPaged != paged) {
 669       sim_printf ("cachedPaged %01o != paged %01o\r\n",
 670               cachedPaged, paged);
 671       err = true;
 672     }
 673     if (err) {
 674 # if defined(HDBG)
 675       HDBGPrint ();
 676 # endif /* if defined(HDBG) */
 677       sim_printf ("oprnd read err  %d %05o:%06o\r\n",
 678               evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 679       exit (1);
 680     }
 681     //sim_printf ("hit  %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 682 # if defined(HDBG)
 683     hdbgNote ("doAppendCycleOperandRead.h", "test hit %d %05o:%06o\r\n",
 684             evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 685 # endif /* if defined(HDBG) */
 686   } else {
 687     //sim_printf ("miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 688 # if defined(HDBG)
 689     hdbgNote ("doAppendCycleOperandRead.h", "test miss %d %05o:%06o\r\n",
 690             evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 691 # endif /* if defined(HDBG) */
 692   }
 693 #endif
 694 
 695   ucCacheSave (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, bound, p, pageAddress, RSDWH_R1, paged);
 696 #if defined(TEST_UCACHE)
 697 # if defined(HDBG)
 698   hdbgNote ("doAppendCycleOperandRead.h", "cache %d %u %05o:%06o %05o %o %08o %o %o",
 699           evcnt, this, cpu.TPR.TSR, cpu.TPR.CA, bound, p, pageAddress, RSDWH_R1, paged);
 700 # endif /* if defined(HDBG) */
 701 #endif /* if defined(TEST_UCACHE) */
 702 evcnt ++;
 703 
 704   // isolts 870
 705   cpu.cu.XSF = 1;
 706   if (full && cpu.currentInstruction.b29)   // (1), see FULL_MODEL_ON
 707     cpu.xsfScu = true;
 708   sim_debug (DBG_TRACEEXT, & cpu_dev, "loading of cpu.TPR.TSR sets XSF to 1\r\n");
 709 
 710   if (full)
 711     cache_readN (cpup, finalAddress, data, nWords, "OPERAND_READ");
 712   else
 713     core_readN_fast (cpup, finalAddress, data, nWords, "OPERAND_READ");
 714 
 715   if (i->info->flags & CALL6_INS)
 716     goto N;
 717 
 718   // Transfer or instruction fetch?
 719   if (i->info->flags & TRANSFER_INS)
 720     goto L;
 721 
 722   // APU data movement?
 723   //  handled above
 724   goto Exit;
 725 
 726 ////////////////////////////////////////
 727 //
 728 // Sheet 10: "K", "L", "M", "N"
 729 //
 730 ////////////////////////////////////////
 731 
 732 L:; // Transfer or instruction fetch
 733 
 734   DBGAPP ("doAppendCycleOperandRead(L)\r\n");
 735 
 736   // Is OPCODE tspn?
 737   if (i->info->flags & TSPN_INS) {
 738     if (i->opcode <= 0273)
 739       n = (i->opcode & 3);
 740     else
 741       n = (i->opcode & 3) + 4;
 742 
 743     // C(PPR.PRR) -> C(PRn .RNR)
 744     // C(PPR.PSR) -> C(PRn .SNR)
 745     // C(PPR.IC) -> C(PRn .WORDNO)
 746     // 000000 -> C(PRn .BITNO)
 747     cpu.PR[n].RNR = cpu.PPR.PRR;
 748 // According the AL39, the PSR is 'undefined' in absolute mode.
 749 // ISOLTS thinks means don't change the operand
 750     if (get_addr_mode (cpup) == APPEND_mode)
 751       cpu.PR[n].SNR = cpu.PPR.PSR;
 752     cpu.PR[n].WORDNO = (cpu.PPR.IC + 1) & MASK18;
 753     SET_PR_BITNO (n, 0);
 754 #if defined(TESTING)
 755     HDBGRegPRW (n, "app tspn");
 756 #endif /* if defined(TESTING) */
 757   }
 758 
 759 // KL:
 760   DBGAPP ("doAppendCycleOperandRead(KL)\r\n");
 761 
 762   // C(TPR.TSR) -> C(PPR.PSR)
 763   cpu.PPR.PSR = cpu.TPR.TSR;
 764   // C(TPR.CA) -> C(PPR.IC)
 765   cpu.PPR.IC = cpu.TPR.CA;
 766 
 767   //goto M;
 768 
 769 M: // Set P
 770   DBGAPP ("doAppendCycleOperandRead(M)\r\n");
 771 
 772   // C(TPR.TRR) = 0?
 773   if (cpu.TPR.TRR == 0) {
 774     // C(SDW.P) -> C(PPR.P)
 775     cpu.PPR.P = p;
 776   } else {
 777     // 0 C(PPR.P)
 778     cpu.PPR.P = 0;
 779   }
 780 
 781   goto Exit;
 782 
 783 N: // CALL6
 784   DBGAPP ("doAppendCycleOperandRead(N)\r\n");
 785 
 786   // C(TPR.TRR) = C(PPR.PRR)?
 787   if (cpu.TPR.TRR == cpu.PPR.PRR) {
 788     // C(PR6.SNR) -> C(PR7.SNR)
 789     cpu.PR[7].SNR = cpu.PR[6].SNR;
 790     DBGAPP ("doAppendCycleOperandRead(N) PR7.SNR = PR6.SNR %05o\r\n", cpu.PR[7].SNR);
 791   } else {
 792     // C(DSBR.STACK) || C(TPR.TRR) -> C(PR7.SNR)
 793     cpu.PR[7].SNR = ((word15) (cpu.DSBR.STACK << 3)) | cpu.TPR.TRR;
 794     DBGAPP ("doAppendCycleOperandRead(N) STACK %05o TRR %o\r\n", cpu.DSBR.STACK, cpu.TPR.TRR);
 795     DBGAPP ("doAppendCycleOperandRead(N) PR7.SNR = STACK||TRR  %05o\r\n", cpu.PR[7].SNR);
 796   }
 797 
 798   // C(TPR.TRR) -> C(PR7.RNR)
 799   cpu.PR[7].RNR = cpu.TPR.TRR;
 800   // 00...0 -> C(PR7.WORDNO)
 801   cpu.PR[7].WORDNO = 0;
 802   // 000000 -> C(PR7.BITNO)
 803   SET_PR_BITNO (7, 0);
 804 #if defined(TESTING)
 805   HDBGRegPRW (7, "app call6");
 806 #endif /* if defined(TESTING) */
 807   // C(TPR.TRR) -> C(PPR.PRR)
 808   cpu.PPR.PRR = cpu.TPR.TRR;
 809   // C(TPR.TSR) -> C(PPR.PSR)
 810   cpu.PPR.PSR = cpu.TPR.TSR;
 811   // C(TPR.CA) -> C(PPR.IC)
 812   cpu.PPR.IC = cpu.TPR.CA;
 813 
 814   goto M;
 815 
 816 Exit:;
 817 
 818   PNL (cpu.APUDataBusOffset = cpu.TPR.CA;)
 819   PNL (cpu.APUDataBusAddr = finalAddress;)
 820 
 821   PNL (L68_ (cpu.apu.state |= apu_FA;))
 822 
 823   DBGAPP ("doAppendCycleOperandRead (Exit) PRR %o PSR %05o P %o IC %06o\r\n", cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
 824   DBGAPP ("doAppendCycleOperandRead (Exit) TRR %o TSR %05o TBR %02o CA %06o\r\n", cpu.TPR.TRR, cpu.TPR.TSR, cpu.TPR.TBR, cpu.TPR.CA);
 825 
 826   return finalAddress;    // or 0 or -1???
 827 }
 828 #undef TEST_UCACHE

/* [previous][next][first][last][top][bottom][index][help] */