Compiler suggested cleanups

This commit is contained in:
Mark Pizzolato 2013-03-13 22:28:14 -07:00
parent 9bd8305943
commit 28f645aeab
9 changed files with 44 additions and 28 deletions

View file

@ -477,10 +477,11 @@ int32 dsk11(const int32 port, const int32 io, const int32 data) {
sim_debug(OUT_MSG, &dsk_dev, "DSK%i: " ADDRESS_FORMAT " OUT 0x09: %x\n", current_disk, PCX, data); sim_debug(OUT_MSG, &dsk_dev, "DSK%i: " ADDRESS_FORMAT " OUT 0x09: %x\n", current_disk, PCX, data);
if (data & 0x01) { /* step head in */ if (data & 0x01) { /* step head in */
if (current_track[current_disk] == (tracks[current_disk] - 1)) if (current_track[current_disk] == (tracks[current_disk] - 1)) {
sim_debug(TRACK_STUCK_MSG, &dsk_dev, sim_debug(TRACK_STUCK_MSG, &dsk_dev,
"DSK%i: " ADDRESS_FORMAT " Unnecessary step in.\n", "DSK%i: " ADDRESS_FORMAT " Unnecessary step in.\n",
current_disk, PCX); current_disk, PCX);
}
current_track[current_disk]++; current_track[current_disk]++;
if (current_track[current_disk] > (tracks[current_disk] - 1)) if (current_track[current_disk] > (tracks[current_disk] - 1))
current_track[current_disk] = (tracks[current_disk] - 1); current_track[current_disk] = (tracks[current_disk] - 1);
@ -491,10 +492,11 @@ int32 dsk11(const int32 port, const int32 io, const int32 data) {
} }
if (data & 0x02) { /* step head out */ if (data & 0x02) { /* step head out */
if (current_track[current_disk] == 0) if (current_track[current_disk] == 0) {
sim_debug(TRACK_STUCK_MSG, &dsk_dev, sim_debug(TRACK_STUCK_MSG, &dsk_dev,
"DSK%i: " ADDRESS_FORMAT " Unnecessary step out.\n", "DSK%i: " ADDRESS_FORMAT " Unnecessary step out.\n",
current_disk, PCX); current_disk, PCX);
}
current_track[current_disk]--; current_track[current_disk]--;
if (current_track[current_disk] < 0) { if (current_track[current_disk] < 0) {
current_track[current_disk] = 0; current_track[current_disk] = 0;

View file

@ -572,14 +572,16 @@ static int32 checkParameters(void) {
selectedTrack = 0; selectedTrack = 0;
} }
selectedDMA &= ADDRMASK; selectedDMA &= ADDRMASK;
if (hdskLastCommand == HDSK_READ) if (hdskLastCommand == HDSK_READ) {
sim_debug(READ_MSG, &hdsk_dev, "HDSK%d " ADDRESS_FORMAT sim_debug(READ_MSG, &hdsk_dev, "HDSK%d " ADDRESS_FORMAT
" Read Track=%04d Sector=%02d Len=%04d DMA=%04x\n", " Read Track=%04d Sector=%02d Len=%04d DMA=%04x\n",
selectedDisk, PCX, selectedTrack, selectedSector, uptr -> HDSK_SECTOR_SIZE, selectedDMA); selectedDisk, PCX, selectedTrack, selectedSector, uptr -> HDSK_SECTOR_SIZE, selectedDMA);
if (hdskLastCommand == HDSK_WRITE) }
if (hdskLastCommand == HDSK_WRITE) {
sim_debug(WRITE_MSG, &hdsk_dev, "HDSK%d " ADDRESS_FORMAT sim_debug(WRITE_MSG, &hdsk_dev, "HDSK%d " ADDRESS_FORMAT
" Write Track=%04d Sector=%02d Len=%04d DMA=%04x\n", " Write Track=%04d Sector=%02d Len=%04d DMA=%04x\n",
selectedDisk, PCX, selectedTrack, selectedSector, uptr -> HDSK_SECTOR_SIZE, selectedDMA); selectedDisk, PCX, selectedTrack, selectedSector, uptr -> HDSK_SECTOR_SIZE, selectedDMA);
}
return TRUE; return TRUE;
} }

View file

@ -702,12 +702,14 @@ static int32 sio0sCore(const int32 port, const int32 io, const int32 data) {
int32 sio0s(const int32 port, const int32 io, const int32 data) { int32 sio0s(const int32 port, const int32 io, const int32 data) {
const int32 result = sio0sCore(port, io, data); const int32 result = sio0sCore(port, io, data);
if (io == 0) if (io == 0) {
sim_debug(IN_MSG, &sio_dev, "\tSIO_S: " ADDRESS_FORMAT sim_debug(IN_MSG, &sio_dev, "\tSIO_S: " ADDRESS_FORMAT
" IN(0x%03x) = 0x%02x\n", PCX, port, result); " IN(0x%03x) = 0x%02x\n", PCX, port, result);
else if (io) }
else if (io) {
sim_debug(OUT_MSG, &sio_dev, "\tSIO_S: " ADDRESS_FORMAT sim_debug(OUT_MSG, &sio_dev, "\tSIO_S: " ADDRESS_FORMAT
" OUT(0x%03x) = 0x%02x\n", PCX, port, data); " OUT(0x%03x) = 0x%02x\n", PCX, port, data);
}
return result; return result;
} }
@ -750,12 +752,14 @@ static char* printable(char* result, int32 data, const int32 isIn) {
int32 sio0d(const int32 port, const int32 io, const int32 data) { int32 sio0d(const int32 port, const int32 io, const int32 data) {
char buffer[8]; char buffer[8];
const int32 result = sio0dCore(port, io, data); const int32 result = sio0dCore(port, io, data);
if (io == 0) if (io == 0) {
sim_debug(IN_MSG, &sio_dev, "\tSIO_D: " ADDRESS_FORMAT sim_debug(IN_MSG, &sio_dev, "\tSIO_D: " ADDRESS_FORMAT
" IN(0x%03x) = 0x%02x%s\n", PCX, port, result, printable(buffer, result, TRUE)); " IN(0x%03x) = 0x%02x%s\n", PCX, port, result, printable(buffer, result, TRUE));
else if (io) }
else if (io) {
sim_debug(OUT_MSG, &sio_dev, "\tSIO_D: " ADDRESS_FORMAT sim_debug(OUT_MSG, &sio_dev, "\tSIO_D: " ADDRESS_FORMAT
" OUT(0x%03x) = 0x%02x%s\n", PCX, port, data, printable(buffer, data, FALSE)); " OUT(0x%03x) = 0x%02x%s\n", PCX, port, data, printable(buffer, data, FALSE));
}
return result; return result;
} }
@ -1264,10 +1268,11 @@ static void attachCPM(UNIT *uptr) {
/* 'C' option makes sure that file is properly truncated if it had existed before */ /* 'C' option makes sure that file is properly truncated if it had existed before */
sim_quiet = sim_switches & SWMASK ('Q'); /* -q means quiet */ sim_quiet = sim_switches & SWMASK ('Q'); /* -q means quiet */
lastCPMStatus = attach_unit(uptr, cpmCommandLine); lastCPMStatus = attach_unit(uptr, cpmCommandLine);
if (lastCPMStatus != SCPE_OK) if (lastCPMStatus != SCPE_OK) {
sim_debug(VERBOSE_MSG, &simh_device, "SIMH: " ADDRESS_FORMAT sim_debug(VERBOSE_MSG, &simh_device, "SIMH: " ADDRESS_FORMAT
" Cannot open '%s' (%s).\n", PCX, cpmCommandLine, " Cannot open '%s' (%s).\n", PCX, cpmCommandLine,
sim_error_text(lastCPMStatus)); sim_error_text(lastCPMStatus));
}
} }
/* setClockZSDOSAdr points to 6 byte block in M: YY MM DD HH MM SS in BCD notation */ /* setClockZSDOSAdr points to 6 byte block in M: YY MM DD HH MM SS in BCD notation */

View file

@ -243,11 +243,12 @@
#define STK_CHECK(x,y) if (((x) & 0377) < (y)) \ #define STK_CHECK(x,y) if (((x) & 0377) < (y)) \
int_req = int_req | INT_STK int_req = int_req | INT_STK
#define IND_STEP(x) M[x] & A_IND; /* return next level indicator */ \ #define IND_STEP(x) M[x] & A_IND; /* return next level indicator */ \
if ( ((x) <= AUTO_TOP) && ((x) >= AUTO_INC) ) \ if ( ((x) <= AUTO_TOP) && ((x) >= AUTO_INC) ) { \
if ( (x) < AUTO_DEC ) \ if ( (x) < AUTO_DEC ) \
M[x] = (M[x] + 1) & DMASK; \ M[x] = (M[x] + 1) & DMASK; \
else \ else \
M[x] = (M[x] - 1) & DMASK; \ M[x] = (M[x] - 1) & DMASK; \
} \
x = M[x] & AMASK x = M[x] & AMASK
#define INCREMENT_PC PC = (PC + 1) & AMASK /* increment PC */ #define INCREMENT_PC PC = (PC + 1) & AMASK /* increment PC */

View file

@ -2311,7 +2311,9 @@ t_stat dmc_wr(int32 data, int32 PA, int32 access)
if (access == WRITE) if (access == WRITE)
{ {
if (PA & 1) if (PA & 1)
{
sim_debug(DBG_WRN, controller->device, "dmc_wr(), Unexpected non-16-bit write access to SEL%d\n", reg); sim_debug(DBG_WRN, controller->device, "dmc_wr(), Unexpected non-16-bit write access to SEL%d\n", reg);
}
dmc_setreg(controller, PA, data, 1); dmc_setreg(controller, PA, data, 1);
} }
else else

View file

@ -1076,7 +1076,8 @@ switch (j) { /* case on class */
for (cptr = get_glyph (cptr, gbuf, 0); gbuf[0] != 0; for (cptr = get_glyph (cptr, gbuf, 0); gbuf[0] != 0;
cptr = get_glyph (cptr, gbuf, 0)) { cptr = get_glyph (cptr, gbuf, 0)) {
for (i = 0; (opcode[i] != NULL) && for (i = 0; (opcode[i] != NULL) &&
(strcmp (opcode[i], gbuf) != 0) ; i++) ; (strcmp (opcode[i], gbuf) != 0) ; i++)
;
if ((((opc_val[i] >> I_V_CL) & I_M_CL) != j) || if ((((opc_val[i] >> I_V_CL) & I_M_CL) != j) ||
(opcode[i] == NULL)) (opcode[i] == NULL))
return SCPE_ARG; return SCPE_ARG;

View file

@ -2645,11 +2645,12 @@ t_stat xq_svc(UNIT* uptr)
} }
/* resubmit service timer */ /* resubmit service timer */
if ((xq->var->must_poll) || (xq->var->poll && (xq->var->mode != XQ_T_DELQA_PLUS))) if ((xq->var->must_poll) || (xq->var->poll && (xq->var->mode != XQ_T_DELQA_PLUS))) {
if (sim_idle_enab) if (sim_idle_enab)
sim_clock_coschedule(uptr, tmxr_poll); sim_clock_coschedule(uptr, tmxr_poll);
else else
sim_activate(uptr, (tmr_poll*clk_tps)/xq->var->poll); sim_activate(uptr, (tmr_poll*clk_tps)/xq->var->poll);
}
return SCPE_OK; return SCPE_OK;
} }

View file

@ -1739,7 +1739,7 @@ fprintf (st, "console halt (BREAK typed on the console terminal). If BDR<7> is
fprintf (st, "onsole firmware responds to all these conditions by entering its interactive\n"); fprintf (st, "onsole firmware responds to all these conditions by entering its interactive\n");
fprintf (st, "command mode. If BDR<7> is clear, the console firmware boots the operating\n"); fprintf (st, "command mode. If BDR<7> is clear, the console firmware boots the operating\n");
fprintf (st, "system in response to these conditions. This bit can be set and cleared by\n"); fprintf (st, "system in response to these conditions. This bit can be set and cleared by\n");
fprintf (st, "the command “SET CPU AUTOBOOT” (clearing the flag) and “SET CPU NOAUTOBOOT”\n"); fprintf (st, "the command \"SET CPU AUTOBOOT\" (clearing the flag) and \"SET CPU NOAUTOBOOT\"\n");
fprintf (st, "setting the flag. The default value is set.\n"); fprintf (st, "setting the flag. The default value is set.\n");
return SCPE_OK; return SCPE_OK;
} }

View file

@ -88,20 +88,20 @@
/* Macros to handle the flags in the CCR */ /* Macros to handle the flags in the CCR */
#define CCR_ALWAYS_ON (0xC0) /* for 6800 */ #define CCR_ALWAYS_ON (0xC0) /* for 6800 */
#define CCR_MSK (HF|IF|NF|ZF|VF|CF) #define CCR_MSK (HF|IF|NF|ZF|VF|CF)
#define TOGGLE_FLAG(FLAG) (CCR ^= FLAG) #define TOGGLE_FLAG(FLAG) ((CCR) ^= FLAG)
#define SET_FLAG(FLAG) (CCR |= FLAG) #define SET_FLAG(FLAG) ((CCR) |= FLAG)
#define CLR_FLAG(FLAG) (CCR &= ~FLAG) #define CLR_FLAG(FLAG) ((CCR) &= ~FLAG)
#define GET_FLAG(FLAG) (CCR & FLAG) #define GET_FLAG(FLAG) ((CCR) & FLAG)
#define COND_SET_FLAG(COND,FLAG) \ #define COND_SET_FLAG(COND,FLAG) \
if (COND) SET_FLAG(FLAG); else CLR_FLAG(FLAG) if (COND) SET_FLAG(FLAG); else CLR_FLAG(FLAG)
#define COND_SET_FLAG_N(VAR) \ #define COND_SET_FLAG_N(VAR) \
if (VAR & 0x80) SET_FLAG(NF); else CLR_FLAG(NF) if ((VAR) & 0x80) SET_FLAG(NF); else CLR_FLAG(NF)
#define COND_SET_FLAG_Z(VAR) \ #define COND_SET_FLAG_Z(VAR) \
if (VAR == 0) SET_FLAG(ZF); else CLR_FLAG(ZF) if ((VAR) == 0) SET_FLAG(ZF); else CLR_FLAG(ZF)
#define COND_SET_FLAG_H(VAR) \ #define COND_SET_FLAG_H(VAR) \
if (VAR & 0x10) SET_FLAG(HF); else CLR_FLAG(HF) if ((VAR) & 0x10) SET_FLAG(HF); else CLR_FLAG(HF)
#define COND_SET_FLAG_C(VAR) \ #define COND_SET_FLAG_C(VAR) \
if (VAR & 0x100) SET_FLAG(CF); else CLR_FLAG(CF) if ((VAR) & 0x100) SET_FLAG(CF); else CLR_FLAG(CF)
#define COND_SET_FLAG_V(COND) \ #define COND_SET_FLAG_V(COND) \
if (COND) SET_FLAG(VF); else CLR_FLAG(VF) if (COND) SET_FLAG(VF); else CLR_FLAG(VF)
@ -403,7 +403,7 @@ t_stat sim_instr (void)
DAR += 6; DAR += 6;
A &= 0xF0; A &= 0xF0;
A |= (DAR & 0x0F); A |= (DAR & 0x0F);
COND_SET_FLAG(DAR & 0x10,CF); COND_SET_FLAG(DAR & 0x10,CF);
} }
DAR = (A >> 4) & 0x0F; DAR = (A >> 4) & 0x0F;
if (DAR > 9 || get_flag(CF)) { if (DAR > 9 || get_flag(CF)) {
@ -1885,18 +1885,20 @@ int32 get_flag(int32 flg)
void condevalVa(int32 op1, int32 op2) void condevalVa(int32 op1, int32 op2)
{ {
if (get_flag(CF)) if (get_flag(CF)) {
COND_SET_FLAG_V(((op1 & 0x80) && (op2 & 0x80)) || ( COND_SET_FLAG_V(((op1 & 0x80) && (op2 & 0x80)) || (
((op1 & 0x80) == 0) && ((op2 & 0x80) == 0))); ((op1 & 0x80) == 0) && ((op2 & 0x80) == 0)));
}
} }
/* test and set V for subtraction */ /* test and set V for subtraction */
void condevalVs(int32 op1, int32 op2) void condevalVs(int32 op1, int32 op2)
{ {
if (get_flag(CF)) if (get_flag(CF)) {
COND_SET_FLAG_V(((op1 & 0x80) && ((op2 & 0x80) == 0)) || COND_SET_FLAG_V(((op1 & 0x80) && ((op2 & 0x80) == 0)) ||
(((op1 & 0x80) == 0) && (op2 & 0x80))); (((op1 & 0x80) == 0) && (op2 & 0x80)));
}
} }
/* calls from the simulator */ /* calls from the simulator */