From 5fcd6a7960df2eb0ebf0c516fe4bac1abd16216d Mon Sep 17 00:00:00 2001 From: Bill Beech Date: Wed, 11 Jul 2012 11:59:15 -0700 Subject: [PATCH] Updated several file to remove "egregious" errors --- swtp6800/common/bootrom.c | 10 +++--- swtp6800/common/dc-4.c | 9 +++-- swtp6800/common/i2716.c | 7 ++-- swtp6800/common/m6800.c | 76 +++++++++++++++++++-------------------- swtp6800/common/m6810.c | 10 +++--- swtp6800/common/mp-8m.c | 8 ++--- 6 files changed, 57 insertions(+), 63 deletions(-) diff --git a/swtp6800/common/bootrom.c b/swtp6800/common/bootrom.c index 608ecae0..c3ecc6e8 100644 --- a/swtp6800/common/bootrom.c +++ b/swtp6800/common/bootrom.c @@ -144,7 +144,7 @@ t_stat BOOTROM_config (UNIT *uptr, int32 val, char *cptr, void *desc) if (val == UNIT_NONE) BOOTROM_unit.capac = 0; /* set EPROM size */ else - BOOTROM_unit.capac = 0x200 << (val >> UNIT_V_MSIZE) - 1; /* set EPROM size */ + BOOTROM_unit.capac = 0x200 << ((val >> UNIT_V_MSIZE) - 1); /* set EPROM size */ if (BOOTROM_unit.filebuf) { /* free buffer */ free (BOOTROM_unit.filebuf); BOOTROM_unit.filebuf = NULL; @@ -161,9 +161,9 @@ t_stat BOOTROM_config (UNIT *uptr, int32 val, char *cptr, void *desc) t_stat BOOTROM_reset (DEVICE *dptr) { - int j, c; + t_addr j; + int c; FILE *fp; - t_stat r; if (BOOTROM_dev.dctrl & DEBUG_flow) printf("BOOTROM_reset: \n"); @@ -195,7 +195,7 @@ t_stat BOOTROM_reset (DEVICE *dptr) j = 0; /* load EPROM file */ c = fgetc(fp); while (c != EOF) { - *(uint8 *)(BOOTROM_unit.filebuf + j++) = c & 0xFF; + *((uint8 *)(BOOTROM_unit.filebuf) + j++) = c & 0xFF; c = fgetc(fp); if (j > BOOTROM_unit.capac) { printf("\tImage is too large - Load truncated!!!\n"); @@ -222,7 +222,7 @@ int32 BOOTROM_get_mbyte(int32 offset) } if (BOOTROM_dev.dctrl & DEBUG_read) printf("BOOTROM_get_mbyte: offset=%04X\n", offset); - val = *(uint8 *)(BOOTROM_unit.filebuf + offset) & 0xFF; + val = *((uint8 *)(BOOTROM_unit.filebuf) + offset) & 0xFF; if (BOOTROM_dev.dctrl & DEBUG_read) printf("BOOTROM_get_mbyte: Normal val=%02X\n", val); return val; diff --git a/swtp6800/common/dc-4.c b/swtp6800/common/dc-4.c index d4379808..80cfd54d 100644 --- a/swtp6800/common/dc-4.c +++ b/swtp6800/common/dc-4.c @@ -368,7 +368,6 @@ t_stat dsk_reset (DEVICE *dptr) int32 fdcdrv(int32 io, int32 data) { static long pos; - char buf[128]; if (io) { /* write to DC-4 drive register */ if (dsk_dev.dctrl & DEBUG_write) @@ -394,9 +393,9 @@ int32 fdcdrv(int32 io, int32 data) sim_fread(dsk_unit[cur_dsk].filebuf, SECSIZ, 1, dsk_unit[cur_dsk].fileref); /* read in buffer */ dsk_unit[cur_dsk].u3 |= BUSY | DRQ; /* set DRQ & BUSY */ dsk_unit[cur_dsk].pos = 0; /* clear counter */ - spt = *(uint8 *)(dsk_unit[cur_dsk].filebuf + MAXSEC) & 0xFF; + spt = *((uint8 *)(dsk_unit[cur_dsk].filebuf) + MAXSEC) & 0xFF; heds = 0; - cpd = *(uint8 *)(dsk_unit[cur_dsk].filebuf + MAXCYL) & 0xFF; + cpd = *((uint8 *)(dsk_unit[cur_dsk].filebuf) + MAXCYL) & 0xFF; trksiz = spt * SECSIZ; dsksiz = trksiz * cpd; if (dsk_dev.dctrl & DEBUG_read) @@ -538,7 +537,7 @@ int32 fdcdata(int32 io, int32 data) if (dsk_unit[cur_dsk].pos < SECSIZ) { /* copy bytes to buffer */ if (dsk_dev.dctrl & DEBUG_write) printf("\nfdcdata: Writing byte %d of %02X", dsk_unit[cur_dsk].pos, data); - *(uint8 *)(dsk_unit[cur_dsk].filebuf + dsk_unit[cur_dsk].pos) = data; /* byte into buffer */ + *((uint8 *)(dsk_unit[cur_dsk].filebuf) + dsk_unit[cur_dsk].pos) = data; /* byte into buffer */ dsk_unit[cur_dsk].pos++; /* step counter */ if (dsk_unit[cur_dsk].pos == SECSIZ) { dsk_unit[cur_dsk].u3 &= ~(BUSY | DRQ); @@ -555,7 +554,7 @@ int32 fdcdata(int32 io, int32 data) if (dsk_unit[cur_dsk].pos < SECSIZ) { /* copy bytes from buffer */ if (dsk_dev.dctrl & DEBUG_read) printf("\nfdcdata: Reading byte %d u3=%02X", dsk_unit[cur_dsk].pos, dsk_unit[cur_dsk].u3); - val = *(uint8 *)(dsk_unit[cur_dsk].filebuf + dsk_unit[cur_dsk].pos) & 0xFF; + val = *((uint8 *)(dsk_unit[cur_dsk].filebuf) + dsk_unit[cur_dsk].pos) & 0xFF; dsk_unit[cur_dsk].pos++; /* step counter */ if (dsk_unit[cur_dsk].pos == SECSIZ) { /* done? */ dsk_unit[cur_dsk].u3 &= ~(BUSY | DRQ); /* clear flags */ diff --git a/swtp6800/common/i2716.c b/swtp6800/common/i2716.c index 77d4f61e..5395055e 100644 --- a/swtp6800/common/i2716.c +++ b/swtp6800/common/i2716.c @@ -130,7 +130,7 @@ t_stat i2716_attach (UNIT *uptr, char *cptr) j = 0; /* load EPROM file */ c = fgetc(fp); while (c != EOF) { - *(uint8 *)(uptr->filebuf + j++) = c & 0xFF; + *((uint8 *)(uptr->filebuf) + j++) = c & 0xFF; c = fgetc(fp); if (j > 2048) { printf("\tImage is too large - Load truncated!!!\n"); @@ -150,8 +150,7 @@ t_stat i2716_attach (UNIT *uptr, char *cptr) t_stat i2716_reset (DEVICE *dptr) { - int32 i, j, c, base; - t_stat r; + int32 i, base; UNIT *uptr; if (i2716_dev.dctrl & DEBUG_flow) @@ -207,7 +206,7 @@ int32 i2716_get_mbyte(int32 offset) printf("i2716_get_mbyte: EPROM not configured\n"); return 0xFF; } else { - val = *(uint8 *)(uptr->filebuf + (offset - org)); + val = *((uint8 *)(uptr->filebuf) + (offset - org)); if (i2716_dev.dctrl & DEBUG_read) printf(" val=%04X\n", val); return (val & 0xFF); diff --git a/swtp6800/common/m6800.c b/swtp6800/common/m6800.c index c0df27e0..c7f8bf02 100644 --- a/swtp6800/common/m6800.c +++ b/swtp6800/common/m6800.c @@ -77,7 +77,7 @@ #define UNIT_V_MSTOP (UNIT_V_UF+1) /* Stop on Invalid memory? */ #define UNIT_MSTOP (1 << UNIT_V_MSTOP) -/* Flag values to set proper positions in CCR */ +/* Flag values to set proper positions in CCR */ #define HF 0x20 #define IF 0x10 #define NF 0x08 @@ -85,7 +85,7 @@ #define VF 0x02 #define CF 0x01 -/* 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_MSK (HF|IF|NF|ZF|VF|CF) #define TOGGLE_FLAG(FLAG) (CCR ^= FLAG) @@ -105,7 +105,7 @@ #define COND_SET_FLAG_V(COND) \ if (COND) SET_FLAG(VF); else CLR_FLAG(VF) -/* local global variables */ +/* local global variables */ int32 A = 0; /* Accumulator A */ int32 B = 0; /* Accumulator B */ @@ -122,7 +122,7 @@ int32 mem_fault = 0; /* memory fault flag */ extern int32 sim_int_char; extern uint32 sim_brk_types, sim_brk_dflt, sim_brk_summ; /* breakpoint info */ -/* function prototypes */ +/* function prototypes */ t_stat m6800_reset (DEVICE *dptr); void dump_regs(void); @@ -145,7 +145,7 @@ int32 get_flag(int32 flag); void condevalVa(int32 op1, int32 op2); void condevalVs(int32 op1, int32 op2); -/* external routines */ +/* external routines */ extern void CPU_BD_put_mbyte(int32 addr, int32 val); extern void CPU_BD_put_mword(int32 addr, int32 val); @@ -153,12 +153,12 @@ extern int32 CPU_BD_get_mbyte(int32 addr); extern int32 CPU_BD_get_mword(int32 addr); extern int32 sim_switches; -/* CPU data structures +/* CPU data structures - m6800_dev CPU device descriptor - m6800_unit CPU unit descriptor - m6800_reg CPU register list - m6800_mod CPU modifiers list */ + m6800_dev CPU device descriptor + m6800_unit CPU unit descriptor + m6800_reg CPU register list + m6800_mod CPU modifiers list */ UNIT m6800_unit = { UDATA (NULL, 0, 0) }; @@ -303,8 +303,6 @@ int32 oplen[256] = { 3,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3 }; -/* simulator instruction decode routine */ - int32 sim_instr (void) { extern int32 sim_interval; @@ -318,10 +316,8 @@ int32 sim_instr (void) while (reason == 0) { /* loop until halted */ // dump_regs1(); if (sim_interval <= 0) /* check clock queue */ - if (reason = sim_process_event ()) { -// printf("sim_process_event()=%08X\n", reason); + if (reason = sim_process_event ()) break; - } if (mem_fault) { /* memory fault? */ mem_fault = 0; /* reset fault flag */ reason = STOP_MEMORY; @@ -1742,7 +1738,7 @@ int32 fetch_byte(int32 flag) { uint8 val; - val = CPU_BD_get_mbyte(PC) & 0xFF; /* fetch byte */ + val = CPU_BD_get_mbyte(PC) & 0xFF; /* fetch byte */ if (m6800_dev.dctrl & DEBUG_asm) { /* display source code */ switch (flag) { case 0: /* opcode fetch */ @@ -1762,7 +1758,7 @@ int32 fetch_word(void) { uint16 val; - val = CPU_BD_get_mbyte(PC) << 8; /* fetch high byte */ + val = CPU_BD_get_mbyte(PC) << 8; /* fetch high byte */ val |= CPU_BD_get_mbyte(PC + 1) & 0xFF; /* fetch low byte */ if (m6800_dev.dctrl & DEBUG_asm) printf("0%04XH", val); @@ -1804,8 +1800,8 @@ uint16 pop_word(void) return res; } -/* This routine does the jump to relative offset if the condition is - met. Otherwise, execution continues at the current PC. */ +/* this routine does the jump to relative offset if the condition is + met. Otherwise, execution continues at the current PC. */ void go_rel(int32 cond) { @@ -1817,7 +1813,7 @@ void go_rel(int32 cond) PC &= ADDRMASK; } -/* returns the relative offset sign-extended */ +/* returns the relative offset sign-extended */ int32 get_rel_addr(void) { @@ -1829,14 +1825,14 @@ int32 get_rel_addr(void) return temp & ADDRMASK; } -/* returns the value at the direct address pointed to by PC */ +/* returns the value at the direct address pointed to by PC */ int32 get_dir_val(void) { return CPU_BD_get_mbyte(get_dir_addr()); } -/* returns the direct address pointed to by PC */ +/* returns the direct address pointed to by PC */ int32 get_dir_addr(void) { @@ -1846,14 +1842,14 @@ int32 get_dir_addr(void) return temp & 0xFF; } -/* returns the value at the indirect address pointed to by PC */ +/* returns the value at the indirect address pointed to by PC */ int32 get_indir_val(void) { return CPU_BD_get_mbyte(get_indir_addr()); } -/* returns the indirect address pointed to by PC or immediate byte */ +/* returns the indirect address pointed to by PC or immediate byte */ int32 get_indir_addr(void) { @@ -1863,14 +1859,14 @@ int32 get_indir_addr(void) return temp; } -/* returns the value at the extended address pointed to by PC */ +/* returns the value at the extended address pointed to by PC */ int32 get_ext_val(void) { return CPU_BD_get_mbyte(get_ext_addr()); } -/* returns the extended address pointed to by PC or immediate word */ +/* returns the extended address pointed to by PC or immediate word */ int32 get_ext_addr(void) { @@ -1880,7 +1876,7 @@ int32 get_ext_addr(void) return temp; } -/* return 1 for flag set or 0 for flag clear */ +/* return 1 for flag set or 0 for flag clear */ int32 get_flag(int32 flg) { @@ -1890,27 +1886,27 @@ int32 get_flag(int32 flg) return 0; } -/* test and set V for addition */ +/* test and set V for addition */ void condevalVa(int32 op1, int32 op2) { if (get_flag(CF)) 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) { if (get_flag(CF)) - COND_SET_FLAG_V(((op1 & 0x80) && (op2 & 0x80 == 0)) || - ((op1 & 0x80 == 0) && (op2 & 0x80))); + COND_SET_FLAG_V(((op1 & 0x80) && ((op2 & 0x80) == 0)) || + (((op1 & 0x80) == 0) && (op2 & 0x80))); } -/* calls from the simulator */ +/* calls from the simulator */ -/* Reset routine */ +/* Reset routine */ t_stat m6800_reset (DEVICE *dptr) { @@ -1926,9 +1922,9 @@ t_stat m6800_reset (DEVICE *dptr) } -/* This is the dumper/loader. This command uses the -h to signify a - hex dump/load vice a binary one. If no address is given to load, it - takes the address from the hex record or the current PC for binary. +/* This is the dumper/loader. This command uses the -h to signify a + hex dump/load vice a binary one. If no address is given to load, it + takes the address from the hex record or the current PC for binary. */ int32 sim_load (FILE *fileref, char *cptr, char *fnam, int flag) @@ -1946,7 +1942,7 @@ int32 sim_load (FILE *fileref, char *cptr, char *fnam, int flag) return (SCPE_OK); } -/* Symbolic output +/* Symbolic output Inputs: *of = output stream @@ -2002,7 +1998,7 @@ int32 fprint_sym (FILE *of, int32 addr, uint32 *val, UNIT *uptr, int32 sw) return SCPE_ARG; } -/* Symbolic input +/* Symbolic input Inputs: *cptr = pointer to input string @@ -2019,4 +2015,4 @@ int32 parse_sym (char *cptr, int32 addr, UNIT *uptr, uint32 *val, int32 sw) return (-2); } -/* end of m6800.c */ +/* end of m6800.c */ diff --git a/swtp6800/common/m6810.c b/swtp6800/common/m6810.c index 382b6794..3bb5660a 100644 --- a/swtp6800/common/m6810.c +++ b/swtp6800/common/m6810.c @@ -111,12 +111,12 @@ t_stat m6810_reset (DEVICE *dptr) int32 m6810_get_mbyte(int32 offset) { - int32 val, org, len; + int32 val; if (m6810_dev.dctrl & DEBUG_read) printf("m6810_get_mbyte: offset=%04X\n", offset); - if (offset < m6810_unit.capac) { - val = *(uint8 *)(m6810_unit.filebuf + offset) & 0xFF; + if (((t_addr)offset) < m6810_unit.capac) { + val = *((uint8 *)(m6810_unit.filebuf) + offset) & 0xFF; if (m6810_dev.dctrl & DEBUG_read) printf("val=%04X\n", val); return val; @@ -133,8 +133,8 @@ void m6810_put_mbyte(int32 offset, int32 val) { if (m6810_dev.dctrl & DEBUG_write) printf("m6810_put_mbyte: offset=%04X, val=%02X\n", offset, val); - if (offset < m6810_unit.capac) { - *(uint8 *)(m6810_unit.filebuf + offset) = val & 0xFF; + if ((t_addr)offset < m6810_unit.capac) { + *((uint8 *)(m6810_unit.filebuf) + offset) = val & 0xFF; return; } else { if (m6810_dev.dctrl & DEBUG_write) diff --git a/swtp6800/common/mp-8m.c b/swtp6800/common/mp-8m.c index 8b6e9b9a..9126b05a 100644 --- a/swtp6800/common/mp-8m.c +++ b/swtp6800/common/mp-8m.c @@ -120,7 +120,7 @@ t_stat mp_8m_reset (DEVICE *dptr) } for (j=0; j<8192; j++) { /* fill pattern for testing */ val = (0xA0 | i); - *(uint8 *)(uptr->filebuf + j) = val & 0xFF; + *((uint8 *)(uptr->filebuf) + j) = val & 0xFF; } } if (mp_8m_dev.dctrl & DEBUG_flow) @@ -151,7 +151,7 @@ int32 mp_8m_get_mbyte(int32 addr) org = uptr->u3; len = uptr->capac - 1; if ((addr >= org) && (addr <= org + len)) { - val = *(uint8 *)(uptr->filebuf + (addr - org)); + val = *((uint8 *)(uptr->filebuf) + (addr - org)); if (mp_8m_dev.dctrl & DEBUG_read) printf(" val=%04X\n", val); return (val & 0xFF); @@ -177,7 +177,7 @@ int32 mp_8m_get_mword(int32 addr) void mp_8m_put_mbyte(int32 addr, int32 val) { - int32 org, len, type; + int32 org, len; int32 i; UNIT *uptr; @@ -188,7 +188,7 @@ void mp_8m_put_mbyte(int32 addr, int32 val) org = uptr->u3; len = uptr->capac - 1; if ((addr >= org) && (addr < org + len)) { - *(uint8 *)(uptr->filebuf + (addr - org)) = val & 0xFF; + *((uint8 *)(uptr->filebuf) + (addr - org)) = val & 0xFF; if (mp_8m_dev.dctrl & DEBUG_write) printf("\n"); return;