KA10: Cleanup some extended addressing issues with KL10B.

Clean up coverity errors.
This commit is contained in:
Richard Cornwell 2022-03-12 15:48:49 -05:00
parent c117a0bd06
commit b566ea356f

View file

@ -1306,7 +1306,7 @@ t_stat dev_mtr(uint32 dev, uint64 *data) {
*data = mtr_irq; *data = mtr_irq;
if (mtr_enable) if (mtr_enable)
*data |= 02000; *data |= 02000;
*data |= (uint64)(mtr_flags << 12); *data |= (uint64)mtr_flags << 12;
sim_debug(DEBUG_CONI, &cpu_dev, "CONI MTR %012llo\n", *data); sim_debug(DEBUG_CONI, &cpu_dev, "CONI MTR %012llo\n", *data);
break; break;
@ -4474,23 +4474,18 @@ no_fetch:
if (QKLB && t20_page) { if (QKLB && t20_page) {
if (xct_flag != 0) { if (xct_flag != 0) {
if (((xct_flag & 8) != 0 && !ptr_flg) || if (((xct_flag & 8) != 0 && !ptr_flg) ||
((xct_flag & 2) != 0 && ptr_flg) ((xct_flag & 2) != 0 && ptr_flg))
/* The following two lines are needed for Tops20 V3 */ sect = cur_sect = prev_sect;
#if 1 #if 0
|| ((xct_flag & 014) == 04 && !ptr_flg && prev_sect == 0) || /* The following lines are needed to run Tops 20 V3 on KL/B */
((xct_flag & 03) == 01 && ptr_flg && prev_sect == 0) if (((xct_flag & 014) == 04 && !ptr_flg && prev_sect == 0)
#endif || ((xct_flag & 03) == 01 && ptr_flg && prev_sect == 0))
)
sect = cur_sect = prev_sect; sect = cur_sect = prev_sect;
}
/* Short cut for extended pointer address */
if (ptr_flg && (glb_sect || cur_sect != 0) && (AR & BIT12) != 0) { /* Full pointer */
ind = 1; /* Allow us to read word, xDB has already bumped AB */
goto in_loop;
}
}
#endif #endif
}
}
#endif
/* Handle indirection repeat until no longer indirect */ /* Handle indirection repeat until no longer indirect */
do { do {
ind = TST_IND(MB) != 0; ind = TST_IND(MB) != 0;
@ -4539,7 +4534,7 @@ in_loop:
if (MB & SMASK || cur_sect == 0) { /* Instruction format IFIW */ if (MB & SMASK || cur_sect == 0) { /* Instruction format IFIW */
if (MB & BIT1 && cur_sect != 0) { /* Illegal index word */ if (MB & BIT1 && cur_sect != 0) { /* Illegal index word */
fault_data = 024LL << 30 | (((FLAGS & USER) != 0)?SMASK:0) | fault_data = 024LL << 30 | (((FLAGS & USER) != 0)?SMASK:0) |
(MB & RMASK) | ((uint64)cur_sect << 18); BIT8 | (AB & RMASK) | ((uint64)cur_sect << 18);
page_fault = 1; page_fault = 1;
goto last; goto last;
} }
@ -4581,9 +4576,10 @@ in_loop:
else else
AR = get_reg(ix); AR = get_reg(ix);
if ((AR & SMASK) != 0 || (AR & SECTM) == 0) { /* Local index word */ if ((AR & SMASK) != 0 || (AR & SECTM) == 0) { /* Local index word */
AR = AB + (((AR & RSIGN) ? 0: 0)|(AR & RMASK)); AR = AB + (AR & RMASK);
} else } else
AR = AR + AB; AR = (AR & ~(SECTM|RMASK)) |
((AR + AB) & (SECTM|RMASK));
AR &= FMASK; AR &= FMASK;
MB = AR; MB = AR;
} else } else
@ -5787,8 +5783,12 @@ dpnorm:
goto last; goto last;
AR = MB; AR = MB;
AB = (AB + 1) & RMASK; AB = (AB + 1) & RMASK;
#if KI
FLAGS |= BYTI;
#endif
if (Mem_read(0, 0, 0, 0)) if (Mem_read(0, 0, 0, 0))
goto last; goto last;
FLAGS &= ~BYTI;
MQ = MB; MQ = MB;
set_reg(AC, AR); set_reg(AC, AR);
set_reg(AC+1, MQ); set_reg(AC+1, MQ);
@ -5799,8 +5799,12 @@ dpnorm:
goto last; goto last;
AR = MB; AR = MB;
AB = (AB + 1) & RMASK; AB = (AB + 1) & RMASK;
#if KI
FLAGS |= BYTI;
#endif
if (Mem_read(0, 0, 0, 0)) if (Mem_read(0, 0, 0, 0))
goto last; goto last;
FLAGS &= ~BYTI;
MQ = CCM(MB) + 1; /* Low */ MQ = CCM(MB) + 1; /* Low */
/* High */ /* High */
#if KL | KS #if KL | KS
@ -5878,6 +5882,9 @@ dpnorm:
if ((FLAGS & BYTI)) { if ((FLAGS & BYTI)) {
AB = (AB + 1) & RMASK; AB = (AB + 1) & RMASK;
MB = MQ; MB = MQ;
#if KL
FLAGS &= ~BYTI;
#endif
if (Mem_write(0, 0)) if (Mem_write(0, 0))
goto last; goto last;
FLAGS &= ~BYTI; FLAGS &= ~BYTI;
@ -6404,6 +6411,14 @@ unasign:
if (Mem_write(0,0)) if (Mem_write(0,0))
goto last; goto last;
AB = (AB - 1) & RMASK; AB = (AB - 1) & RMASK;
AR &= PMASK;
AR |= (uint64)(SCAD & 077) << 30;
MB = AR;
if (Mem_write(0, 0))
goto last;
if ((IR & 04) == 0)
break;
goto ldb_ptr;
} else } else
AR = (AR & LMASK) | ((AR + 1) & RMASK); AR = (AR & LMASK) | ((AR + 1) & RMASK);
#elif KI | KS #elif KI | KS
@ -6475,10 +6490,11 @@ ldb_ptr:
#endif #endif
#if KL #if KL
if (QKLB && t20_page && (SC < 36) && if (QKLB && t20_page && (SC < 36) &&
pc_sect != 0 && (glb_sect || cur_sect != 0) && pc_sect != 0 && (AR & BIT12) != 0) {
(AR & BIT12) != 0) {
/* Full pointer */ /* Full pointer */
AB = (AB + 1) & RMASK; AB = (AB + 1) & RMASK;
ind = 1;
goto in_loop;
} else } else
glb_sect = 0; glb_sect = 0;
#endif #endif
@ -12222,7 +12238,7 @@ do_byte_setup(int n, int wr, int *pos, int *sz)
temp = MB = (MB + temp) & FMASK; temp = MB = (MB + temp) & FMASK;
AB = MB & RMASK; AB = MB & RMASK;
} }
while (ind && pi_pending && !check_irq_level()) { if (ind) {
if (Mem_read(0, 1, 0, 0)) { if (Mem_read(0, 1, 0, 0)) {
return 1; return 1;
} }
@ -12262,7 +12278,7 @@ do_byte_setup(int n, int wr, int *pos, int *sz)
if (ix) { if (ix) {
temp = get_reg(ix); temp = get_reg(ix);
if ((temp & SMASK) != 0 || (temp & SECTM) == 0) { /* Local index word */ if ((temp & SMASK) != 0 || (temp & SECTM) == 0) { /* Local index word */
temp = AB + (((temp & RSIGN) ? 0: 0)|(temp & RMASK)); temp = AB + (temp & RMASK);
} else } else
temp = temp + AB; temp = temp + AB;
temp &= FMASK; temp &= FMASK;
@ -12307,10 +12323,13 @@ do_byte_setup(int n, int wr, int *pos, int *sz)
set_reg(n+2, val2); set_reg(n+2, val2);
/* Read final value */ /* Read final value */
ptr_flg = 1;
BYF5 = wr;
if (Mem_read(0, 0, 0, wr)) { if (Mem_read(0, 0, 0, wr)) {
ptr_flg = BYF5 = 0; ptr_flg = BYF5 = 0;
return 1; return 1;
} }
ptr_flg = BYF5 = 0;
return 0; return 0;
} }
@ -12329,11 +12348,9 @@ load_byte(int n, uint64 *data, uint64 fill, int cnt)
} }
/* Fetch Pointer word */ /* Fetch Pointer word */
ptr_flg = 1;
if (do_byte_setup(n, 0, &p, &s)) if (do_byte_setup(n, 0, &p, &s))
goto back; goto back;
ptr_flg = 0;
/* Generate mask for given size */ /* Generate mask for given size */
msk = (uint64)(1) << s; msk = (uint64)(1) << s;
msk--; msk--;
@ -12348,7 +12365,6 @@ ptr_flg = 0;
return 1; return 1;
back: back:
ptr_flg = 0;
val1 = get_reg(n+1); val1 = get_reg(n+1);
val1 &= PMASK; val1 &= PMASK;
val1 |= (uint64)(p + s) << 30; val1 |= (uint64)(p + s) << 30;
@ -12364,7 +12380,6 @@ store_byte(int n, uint64 data, int cnt)
int s, p; int s, p;
/* Fetch Pointer word */ /* Fetch Pointer word */
BYF5 = 1;
if (do_byte_setup(n, 1, &p, &s)) if (do_byte_setup(n, 1, &p, &s))
goto back; goto back;
@ -12374,10 +12389,11 @@ store_byte(int n, uint64 data, int cnt)
msk <<= p; msk <<= p;
MB &= CM(msk); MB &= CM(msk);
MB |= msk & ((uint64)(data) << p); MB |= msk & ((uint64)(data) << p);
ptr_flg = BYF5 = 1;
if (Mem_write(0, 0)) if (Mem_write(0, 0))
goto back; goto back;
BYF5 = 0; ptr_flg = BYF5 = 0;
if (cnt) { if (cnt) {
/* Decrement count */ /* Decrement count */
val1 = get_reg(n); val1 = get_reg(n);
@ -12388,7 +12404,7 @@ store_byte(int n, uint64 data, int cnt)
return 1; return 1;
back: back:
BYF5 = 0; ptr_flg = BYF5 = 0;
val1 = get_reg(n+1); val1 = get_reg(n+1);
val1 &= PMASK; val1 &= PMASK;
val1 |= (uint64)(p + s) << 30; val1 |= (uint64)(p + s) << 30;