diff --git a/HP2100/hp2100_baci.c b/HP2100/hp2100_baci.c index 853e80ba..5018c8f9 100644 --- a/HP2100/hp2100_baci.c +++ b/HP2100/hp2100_baci.c @@ -1,6 +1,6 @@ /* hp2100_baci.c: HP 12966A buffered asynchronous communications interface simulator - Copyright (c) 2007-2013, J. David Bryan + Copyright (c) 2007-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ BACI 12966A BACI card + 24-Dec-14 JDB Added casts for explicit downward conversions 10-Jan-13 MP Added DEV_MUX and additional DEVICE field values 10-Feb-12 JDB Deprecated DEVNO in favor of SC Removed DEV_NET to allow restoration of listening port @@ -366,7 +367,7 @@ static int32 service_time (uint32 control_word); static void update_status (void); static void master_reset (void); -static uint32 fifo_get (void); +static uint16 fifo_get (void); static void fifo_put (uint8 ch); static void clock_uart (void); @@ -871,7 +872,8 @@ while (xmit_loop && (baci_uart_thr & IN_VALID)) { /* valid character in UA if ((status == SCPE_OK) && /* transmitted OK? */ DEBUG_PRI (baci_dev, DEB_XFER)) fprintf (sim_deb, ">>BACI xfer: Character %s " - "transmitted from UART\n", fmt_char (baci_uart_tr)); + "transmitted from UART\n", + fmt_char ((uint8) baci_uart_tr)); } } @@ -915,8 +917,11 @@ if (recv_loop && /* ok to process? */ /* Reception */ -while (recv_loop && /* OK to process? */ - (baci_uart_rr = tmxr_getc_ln (&baci_ldsc))) { /* and new character available? */ +while (recv_loop) { /* OK to process? */ + baci_uart_rr = tmxr_getc_ln (&baci_ldsc); /* get a new character */ + + if (baci_uart_rr == 0) /* if there are no more characters available */ + break; /* then quit the reception loop */ if (baci_uart_rr & SCPE_BREAK) { /* break detected? */ baci_status = baci_status | IN_BREAK; /* set break status */ @@ -925,17 +930,17 @@ while (recv_loop && /* OK to process? */ fputs (">>BACI xfer: Break detected\n", sim_deb); } - data_bits = 5 + (baci_cfcw & OUT_CHARSIZE); /* calculate number of data bits */ - data_mask = (1 << data_bits) - 1; /* generate mask for data bits */ - baci_uart_rhr = baci_uart_rr & data_mask; /* mask data into holding register */ - baci_uart_rr = CLEAR_R; /* clear receiver register */ + data_bits = 5 + (baci_cfcw & OUT_CHARSIZE); /* calculate number of data bits */ + data_mask = (1 << data_bits) - 1; /* generate mask for data bits */ + baci_uart_rhr = (uint16) (baci_uart_rr & data_mask); /* mask data into holding register */ + baci_uart_rr = CLEAR_R; /* clear receiver register */ if (DEBUG_PRI (baci_dev, DEB_XFER)) fprintf (sim_deb, ">>BACI xfer: Character %s received by UART\n", fmt_char ((uint8) baci_uart_rhr)); - if (baci_term.flags & UNIT_CAPSLOCK) /* caps lock mode? */ - baci_uart_rhr = toupper (baci_uart_rhr); /* convert to upper case if lower */ + if (baci_term.flags & UNIT_CAPSLOCK) /* caps lock mode? */ + baci_uart_rhr = (uint16) toupper (baci_uart_rhr); /* convert to upper case if lower */ if (baci_cfcw & OUT_ECHO) /* echo wanted? */ tmxr_putc_ln (&baci_ldsc, baci_uart_rhr); /* send it back */ @@ -1319,9 +1324,9 @@ return ticks [GET_BAUDRATE (control_word)]; /* return service time f not 0. */ -static uint32 fifo_get (void) +static uint16 fifo_get (void) { -uint32 data; +uint16 data; data = baci_fifo [baci_fget]; /* get character */ @@ -1331,7 +1336,8 @@ if ((baci_fget != baci_fput) || (baci_fcount >= 128)) { /* FIFO occupied? */ if (DEBUG_PRI (baci_dev, DEB_BUF)) fprintf (sim_deb, ">>BACI buf: Character %s get from FIFO [%d], " - "character counter = %d\n", fmt_char (data), baci_fget, baci_fcount); + "character counter = %d\n", + fmt_char ((uint8) data), baci_fget, baci_fcount); baci_fget = (baci_fget + 1) % FIFO_SIZE; /* bump index modulo array size */ @@ -1502,14 +1508,15 @@ if (baci_uart_clk > 0) { /* transfer in progress? ((baci_cfcw & OUT_PARITY) != 0) + /* plus parity bit if used */ ((baci_cfcw & OUT_STBITS) != 0); /* plus extra stop bit if used */ - baci_uart_rhr = baci_uart_rr >> (16 - uart_bits); /* position data to right align */ - baci_uart_rr = CLEAR_R; /* clear receiver register */ + baci_uart_rhr = (uint16) (baci_uart_rr >> (16 - uart_bits)); /* position data to right align */ + baci_uart_rr = CLEAR_R; /* clear receiver register */ if (DEBUG_PRI (baci_dev, DEB_XFER)) fprintf (sim_deb, ">>BACI xfer: UART receiver = %06o (%s)\n", - baci_uart_rhr, fmt_char (baci_uart_rhr & data_mask)); + baci_uart_rhr, + fmt_char ((uint8) (baci_uart_rhr & data_mask))); - fifo_put (baci_uart_rhr & data_mask); /* put data in FIFO */ + fifo_put ((uint8) (baci_uart_rhr & data_mask)); /* put data in FIFO */ update_status (); /* update FIFO status */ if (baci_cfcw & OUT_PARITY) { /* parity present? */ @@ -1568,7 +1575,8 @@ if ((baci_uart_clk == 0) && /* start of transfer? */ if (DEBUG_PRI (baci_dev, DEB_XFER)) fprintf (sim_deb, ">>BACI xfer: UART transmitter = %06o (%s), " "clock count = %d\n", baci_uart_tr & DMASK, - fmt_char (baci_uart_thr & data_mask), baci_uart_clk); + fmt_char ((uint8) (baci_uart_thr & data_mask)), + baci_uart_clk); } else { diff --git a/HP2100/hp2100_bugfixes.txt b/HP2100/hp2100_bugfixes.txt index 0d86108e..be2f05e8 100644 --- a/HP2100/hp2100_bugfixes.txt +++ b/HP2100/hp2100_bugfixes.txt @@ -1,6 +1,6 @@ HP 2100 SIMULATOR BUG FIX WRITEUPS ================================== - Last update: 2014-12-19 + Last update: 2015-01-03 1. PROBLEM: Booting from magnetic tape reports "HALT instruction, P: 77756 @@ -6743,3 +6743,49 @@ indications that they are being called in the context of a simulator stop. STATUS: Fixed in version 4.0-0. + + + +265. PROBLEM: Compiling the HP simulator for 64-bit addressing produces many + conversion warnings. + + VERSION: 3.9-0 + + OBSERVATION: Compiling the simulator and defining USE_INT64 and USE_ADDR64 + with implicit conversion warnings enabled reveals a number of places where + assumptions were made that addresses would always be 32 bits. This is a + reasonable assumption, as there are no devices (CPU or peripherals) that + can handle gigabyte addressing. Still, many of these assumptions are not + necessary, and some future peripheral simulator may exceed this limit. + + CAUSE: Future expansion to 64-bit addressing was not envisioned. + + RESOLUTION: Modify source files to ensure that "t_addr" and "t_value" + types are used instead of "uint32" and "int32" types where addressing and + data values may be 64 bits. Also ensure that valid conversions to smaller + sizes use explicit casts. + + STATUS: Fixed in version 4.0-0. + + + +266. PROBLEM: BOOT devices require a duplicate S-register declaration. + + VERSION: 3.9-0 + + OBSERVATION: All of the peripheral devices that support the BOOT command + set the select code and other parameters into the S register during the + boot process. This direct register access requires an external declaration + that duplicates the one in the full CPU declarations file (hp2100_cpu.h). + A better method that avoids the duplicate declaration would be for the + "ibl_copy" routine to modify the S register on behalf of the caller. + + CAUSE: Poor original implementation. + + RESOLUTION: Modify "ibl_copy" (hp2100_cpu.c) to take two additional + parameters that clear and set bits, respectively, in the S register on + behalf of the caller. Modify the boot routines for the CPU, DA, DP, DQ, + DR, DS, IPL, MS, and PTR devices to use the new parameters instead of + modifying the S register directly. + + STATUS: Fixed in version 4.0-0. diff --git a/HP2100/hp2100_cpu.c b/HP2100/hp2100_cpu.c index 5f4ac6e7..14bbfea4 100644 --- a/HP2100/hp2100_cpu.c +++ b/HP2100/hp2100_cpu.c @@ -1,6 +1,6 @@ /* hp2100_cpu.c: HP 21xx/1000 CPU simulator - Copyright (c) 1993-2013, Robert M. Supnik + Copyright (c) 1993-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -29,6 +29,9 @@ DMA1,DMA2 12607B/12578A/12895A direct memory access controller DCPC1,DCPC2 12897B dual channel port controller + 31-Dec-14 JDB Corrected devdisp data parameters + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Added casts for explicit downward conversions 18-Mar-13 JDB Removed redundant extern declarations 05-Feb-13 JDB HLT instruction handler now relies on sim_vm_fprint_stopped 09-May-12 JDB Separated assignments from conditional expressions @@ -1697,7 +1700,7 @@ while (reason == SCPE_OK) { /* loop until halted */ skip = 1; } /* end if ~RSS */ - ABREG[absel] = t; /* store result */ + ABREG[absel] = (uint16) t; /* store result */ PC = (PC + skip) & VAMASK; /* add in skip */ break; /* end if alter/skip */ @@ -1713,8 +1716,8 @@ while (reason == SCPE_OK) { /* loop until halted */ if ((IR & 000010) && ((t & 1) == 0)) /* SLx */ PC = (PC + 1) & VAMASK; - ABREG[absel] = shift (t, IR & 00020, IR); /* do second shift */ - break; /* end if shift */ + ABREG[absel] = (uint16) shift (t, IR & 00020, IR); /* do second shift */ + break; /* end if shift */ /* I/O instructions */ @@ -1971,7 +1974,7 @@ if ((sop == soFLG) && clf) /* CLF instruction? */ else if (clf) /* CLF with another instruction? */ signal_set = signal_set | ioCLF; /* add CLF signal */ -ioreturn = devdisp (dev, signal_set, IORETURN (SCPE_OK, iodata)); /* dispatch I/O signal */ +ioreturn = devdisp (dev, signal_set, iodata); /* dispatch I/O signal */ iostat = IOSTATUS (ioreturn); /* extract status */ iodata = IODATA (ioreturn); /* extract return data value */ @@ -2494,13 +2497,13 @@ return (MAP_GETPAG (mpr) | VA_GETOFF (va)); /* return mapped address used for restoration. */ -static uint32 dms_cons (uint32 va, int32 sw) +static uint32 dms_cons (t_addr va, int32 sw) { uint32 map_sel; if ((dms_enb == 0) || /* DMS off? */ (sw & (SWMASK ('N') | SIM_SW_REST))) /* no mapping rqst or save/rest? */ - return va; /* use physical address */ + return (uint32) va; /* use physical address */ else if (sw & SWMASK ('S')) map_sel = SMAP; @@ -2518,13 +2521,13 @@ else /* dflt to log addr, cur map_sel = dms_ump; if (va >= VASIZE) /* virtual, must be 15b */ - return MEMSIZE; + return (uint32) MEMSIZE; else if (dms_enb) /* DMS on? go thru map */ - return dms (va, map_sel, NOPROT); + return dms ((uint32) va, map_sel, NOPROT); else /* else return virtual */ - return va; + return (uint32) va; } @@ -2754,7 +2757,7 @@ while (working_set) { E = 1; /* set E register */ if (UNIT_CPU_FAMILY == UNIT_FAMILY_1000) { /* 1000 series? */ - memset (M, 0, MEMSIZE * 2); /* zero allocated memory */ + memset (M, 0, (uint32) MEMSIZE * 2); /* zero allocated memory */ MR = 0077777; /* set M register */ PC = 0100000; /* set P register */ } @@ -3081,7 +3084,7 @@ while (working_set) { else if (UNIT_CPU_TYPE == UNIT_TYPE_211X) /* 2115/2116? */ data = dma [ch].cw3 & 0037777; /* only 14-bit count */ else /* other models */ - data = dma [ch].cw3; /* rest use full value */ + data = (uint16) dma [ch].cw3; /* rest use full value */ stat_data = IORETURN (SCPE_OK, data); /* merge status and remaining word count */ break; @@ -3364,8 +3367,7 @@ else { /* last cycle */ } if (input) { /* input cycle? */ - ioresult = devdisp (dev, signals, /* do I/O input */ - IORETURN (SCPE_OK, 0)); + ioresult = devdisp (dev, signals, 0); /* do I/O input */ status = IOSTATUS (ioresult); /* get cycle status */ @@ -3374,8 +3376,8 @@ if (input) { /* input cycle? */ if (bytes) { /* byte packing? */ if (even) { /* second byte? */ - data = (dma [ch].packer << 8) | /* merge stored byte */ - (data & DMASK8); + data = (uint16) (dma [ch].packer << 8) /* merge stored byte */ + | (data & DMASK8); WriteIO (MA, data, map); /* store word data */ } else /* first byte */ @@ -3403,8 +3405,7 @@ else { /* output cycle */ else /* no byte packing */ data = ReadIO (MA, map); /* read word data */ - ioresult = devdisp (dev, signals, /* do I/O output */ - IORETURN (SCPE_OK, data)); + ioresult = devdisp (dev, signals, data); /* do I/O output */ status = IOSTATUS (ioresult); /* get cycle status */ } @@ -3670,7 +3671,7 @@ t_stat cpu_set_size (UNIT *uptr, int32 new_size, char *cptr, void *desc) int32 mc = 0; uint32 i; uint32 model = CPU_MODEL_INDEX; /* current CPU model index */ -uint32 old_size = MEMSIZE; /* current memory size */ +uint32 old_size = (uint32) MEMSIZE; /* current memory size */ if ((uint32) new_size > cpu_features[model].maxmem) return SCPE_NOFNC; /* mem size unsupported */ @@ -3689,10 +3690,10 @@ if (!(sim_switches & SWMASK ('F'))) { /* force truncation? */ if (UNIT_CPU_FAMILY == UNIT_FAMILY_21XX) { /* 21xx CPU? */ cpu_set_ldr (uptr, FALSE, NULL, NULL); /* save loader to shadow RAM */ MEMSIZE = new_size; /* set new memory size */ - fwanxm = MEMSIZE - IBL_LNT; /* reserve memory for loader */ + fwanxm = (uint32) MEMSIZE - IBL_LNT; /* reserve memory for loader */ } else /* loader unsupported */ - fwanxm = MEMSIZE = new_size; /* set new memory size */ + MEMSIZE = fwanxm = new_size; /* set new memory size */ for (i = fwanxm; i < old_size; i++) /* zero non-existent memory */ M[i] = 0; @@ -3779,15 +3780,15 @@ if ((MEMSIZE == 0) || /* current mem size not (MEMSIZE > cpu_features[new_index].maxmem)) /* current mem size too large? */ new_memsize = cpu_features[new_index].maxmem; /* set it to max supported */ else - new_memsize = MEMSIZE; /* or leave it unchanged */ + new_memsize = (uint32) MEMSIZE; /* or leave it unchanged */ result = cpu_set_size (uptr, new_memsize, NULL, NULL); /* set memory size */ if (result == SCPE_OK) /* memory change OK? */ if (new_family == UNIT_FAMILY_21XX) /* 21xx CPU? */ - fwanxm = MEMSIZE - IBL_LNT; /* reserve memory for loader */ + fwanxm = (uint32) MEMSIZE - IBL_LNT; /* reserve memory for loader */ else - fwanxm = MEMSIZE; /* loader reserved only for 21xx */ + fwanxm = (uint32) MEMSIZE; /* loader reserved only for 21xx */ return result; } @@ -3914,7 +3915,7 @@ if ((UNIT_CPU_FAMILY != UNIT_FAMILY_21XX) || /* valid only for 21xx * return SCPE_NOFNC; if (is_enabled && (enable == 0)) { /* disable loader? */ - fwanxm = MEMSIZE - IBL_LNT; /* decrease available memory */ + fwanxm = (uint32) MEMSIZE - IBL_LNT; /* decrease available memory */ for (i = 0; i < IBL_LNT; i++) { /* copy loader */ loader[i] = M[fwanxm + i]; /* from memory */ M[fwanxm + i] = 0; /* and zero location */ @@ -3924,7 +3925,7 @@ if (is_enabled && (enable == 0)) { /* disable loader? */ else if ((!is_enabled) && (enable == 1)) { /* enable loader? */ for (i = 0; i < IBL_LNT; i++) /* copy loader */ M[fwanxm + i] = loader[i]; /* to memory */ - fwanxm = MEMSIZE; /* increase available memory */ + fwanxm = (uint32) MEMSIZE; /* increase available memory */ } return SCPE_OK; @@ -3963,19 +3964,19 @@ if (dev < 010) switch (sel) { case 0: /* PTR boot */ - ibl_copy (ptr_rom, dev); + ibl_copy (ptr_rom, dev, IBL_S_NOCLR, IBL_S_NOSET); break; case 1: /* DP/DQ boot */ - ibl_copy (dq_rom, dev); + ibl_copy (dq_rom, dev, IBL_S_NOCLR, IBL_S_NOSET); break; case 2: /* MS boot */ - ibl_copy (ms_rom, dev); + ibl_copy (ms_rom, dev, IBL_S_NOCLR, IBL_S_NOSET); break; case 3: /* DS boot */ - ibl_copy (ds_rom, dev); + ibl_copy (ds_rom, dev, IBL_S_NOCLR, IBL_S_NOSET); break; } @@ -3988,14 +3989,14 @@ return SCPE_OK; - Use memory size to set the initial PC and base of the boot area - Copy boot ROM to memory, updating I/O instructions - Place 2s complement of boot base in last location + - Modify S register as indicated Notes: - - SR settings are done by the caller - Boot ROMs must be assembled with a device code of 10 (10 and 11 for devices requiring two codes) */ -t_stat ibl_copy (const BOOT_ROM rom, int32 dev) +t_stat ibl_copy (const BOOT_ROM rom, int32 dev, uint32 sr_clear, uint32 sr_set) { int32 i; uint16 wd; @@ -4021,5 +4022,8 @@ for (i = 0; i < IBL_LNT; i++) { /* copy bootstrap */ M[PC + IBL_DPC] = (M[PC + IBL_DPC] + (dev - 010)) & DMASK; /* patch DMA ctrl */ M[PC + IBL_END] = (~PC + 1) & DMASK; /* fill in start of boot */ + +SR = (SR & sr_clear) | sr_set; /* modify the S register as indicated */ + return SCPE_OK; } diff --git a/HP2100/hp2100_cpu.h b/HP2100/hp2100_cpu.h index b131511f..614e3273 100644 --- a/HP2100/hp2100_cpu.h +++ b/HP2100/hp2100_cpu.h @@ -1,6 +1,6 @@ /* hp2100_cpu.h: HP 2100 CPU definitions - Copyright (c) 2005-2013, Robert M. Supnik + Copyright (c) 2005-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -23,6 +23,7 @@ be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Robert M Supnik. + 24-Dec-14 JDB Added casts for explicit downward conversions 18-Mar-13 JDB Added declarations for the MP abort handler and CPU registers 14-Mar-13 MP Changed guard macro name to avoid reserved namespace 03-Jan-10 RMS Changed declarations of mp_control, mp_mefvv, for VMS compiler @@ -177,7 +178,7 @@ #define PCQ_SIZE 64 /* must be 2**n */ #define PCQ_MASK (PCQ_SIZE - 1) -#define PCQ_ENTRY pcq[pcq_p = (pcq_p - 1) & PCQ_MASK] = err_PC +#define PCQ_ENTRY pcq[pcq_p = (pcq_p - 1) & PCQ_MASK] = (uint16) err_PC /* Memory reference instructions */ diff --git a/HP2100/hp2100_cpu1.c b/HP2100/hp2100_cpu1.c index 4c00bb2e..bd09d737 100644 --- a/HP2100/hp2100_cpu1.c +++ b/HP2100/hp2100_cpu1.c @@ -25,6 +25,7 @@ CPU1 Extended arithmetic and optional microcode dispatchers + 24-Dec-14 JDB Added casts for explicit downward conversions 05-Apr-14 JDB Corrected typo in comments for cpu_ops 09-May-12 JDB Separated assignments from conditional expressions 11-Sep-08 JDB Moved microcode function prototypes to hp2100_cpu1.h @@ -768,11 +769,11 @@ for (i = 0; i < OP_N_F; i++) { break; case OP_VAR: /* inline variable operand */ - (*op++).word = PC; /* get pointer to variable */ + (*op++).word = (uint16) PC; /* get pointer to variable */ break; case OP_ADR: /* inline address operand */ - (*op++).word = MA; /* get address */ + (*op++).word = (uint16) MA; /* get address (set by "resolve" above) */ break; case OP_ADK: /* address of int constant */ diff --git a/HP2100/hp2100_cpu2.c b/HP2100/hp2100_cpu2.c index a55cf656..716acc93 100644 --- a/HP2100/hp2100_cpu2.c +++ b/HP2100/hp2100_cpu2.c @@ -1,6 +1,6 @@ /* hp2100_cpu2.c: HP 2100/1000 FP/DMS/EIG/IOP instructions - Copyright (c) 2005-2012, Robert M. Supnik + Copyright (c) 2005-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,7 @@ CPU2 Floating-point, dynamic mapping, extended, and I/O processor instructions + 24-Dec-14 JDB Added casts for explicit downward conversions 09-May-12 JDB Separated assignments from conditional expressions 11-Sep-08 JDB Moved microcode function prototypes to hp2100_cpu1.h 05-Sep-08 JDB Removed option-present tests (now in UIG dispatchers) @@ -118,9 +119,12 @@ uint32 entry; entry = (IR >> 4) & 017; /* mask to entry point */ -if (op_fp[entry] != OP_N) - if (reason = cpu_ops (op_fp[entry], op, intrq)) /* get instruction operands */ - return reason; +if (op_fp [entry] != OP_N) { + reason = cpu_ops (op_fp [entry], op, intrq); /* get instruction operands */ + + if (reason != SCPE_OK) /* evaluation failed? */ + return reason; /* return reason for failure */ + } switch (entry) { /* decode IR<7:4> */ @@ -465,11 +469,11 @@ switch (entry) { /* decode IR<3:0> */ break; case 030: /* RSA, RSB 10x730 (OP_N) */ - ABREG[absel] = dms_upd_sr (); /* save stat */ + ABREG[absel] = (uint16) dms_upd_sr (); /* save stat */ break; case 031: /* RVA, RVB 10x731 (OP_N) */ - ABREG[absel] = dms_upd_vr (err_PC); /* return updated violation register */ + ABREG[absel] = (uint16) dms_upd_vr (err_PC); /* return updated violation register */ break; case 032: /* DJP 105732 (OP_A) */ @@ -643,7 +647,7 @@ switch (entry) { /* decode IR<4:0> */ break; case 004: /* CXA, CXB 10x744 (OP_N) */ - ABREG[absel] = XR; /* copy from XR */ + ABREG[absel] = (uint16) XR; /* copy from XR */ break; case 005: /* LDX 105745 (OP_K)*/ @@ -660,7 +664,7 @@ switch (entry) { /* decode IR<4:0> */ case 007: /* XAX, XBX 10x747 (OP_N) */ t = XR; /* exchange XR */ XR = ABREG[absel]; - ABREG[absel] = t; + ABREG[absel] = (uint16) t; break; case 010: /* SAY, SBY 10x750 (OP_A) */ @@ -682,7 +686,7 @@ switch (entry) { /* decode IR<4:0> */ break; case 014: /* CYA, CYB 10x754 (OP_N) */ - ABREG[absel] = YR; /* copy from YR */ + ABREG[absel] = (uint16) YR; /* copy from YR */ break; case 015: /* LDY 105755 (OP_K) */ @@ -699,7 +703,7 @@ switch (entry) { /* decode IR<4:0> */ case 017: /* XAY, XBY 10x757 (OP_N) */ t = YR; /* exchange YR */ YR = ABREG[absel]; - ABREG[absel] = t; + ABREG[absel] = (uint16) t; break; /* EIG module 2 */ @@ -1027,7 +1031,7 @@ switch (entry) { /* decode IR<5:0> */ break; case 002: /* READF 105462 (OP_N) */ - AR = iop_sp; /* copy stk ptr */ + AR = (uint16) iop_sp; /* copy stk ptr */ break; case 003: /* INS 105463 (OP_N) */ diff --git a/HP2100/hp2100_cpu3.c b/HP2100/hp2100_cpu3.c index 3e201aea..8e48372e 100644 --- a/HP2100/hp2100_cpu3.c +++ b/HP2100/hp2100_cpu3.c @@ -1,6 +1,6 @@ /* hp2100_cpu3.c: HP 2100/1000 FFP/DBI instructions - Copyright (c) 2005-2008, J. David Bryan + Copyright (c) 2005-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ CPU3 Fast FORTRAN and Double Integer instructions + 24-Dec-14 JDB Added casts for explicit downward conversions 09-May-12 JDB Separated assignments from conditional expressions 11-Sep-08 JDB Moved microcode function prototypes to hp2100_cpu1.h 05-Sep-08 JDB Removed option-present tests (now in UIG dispatchers) @@ -478,8 +479,8 @@ switch (entry) { /* decode IR<4:0> */ WriteW (da++, MA); /* put addr into formal */ } - AR = ra; /* return address */ - BR = da; /* addr of 1st unused formal */ + AR = (uint16) ra; /* return address */ + BR = (uint16) da; /* addr of 1st unused formal */ break; case 024: /* .ENTP 105224 (OP_A) */ @@ -518,8 +519,8 @@ switch (entry) { /* decode IR<4:0> */ BR = (BR + 1) & VAMASK; /* incr address */ op[0].word = op[0].word - 1; /* decr count */ if (op[0].word && intrq) { /* more and intr? */ - AR = sa; /* restore A */ - BR = sb; /* restore B */ + AR = (uint16) sa; /* restore A */ + BR = (uint16) sb; /* restore B */ PC = err_PC; /* restart instruction */ break; } @@ -725,10 +726,10 @@ switch (entry) { /* decode IR<3:0> */ t = (rh << 16) | (rl & 0xFFFF); /* combine partials */ } - if (O) - t = ~SIGN32; /* if overflow, rtn max pos */ - else if (sign) - t = ~t + 1; /* if result neg, 2s compl */ + if (O) /* if overflow occurred */ + t = ~SIGN32; /* then return the largest positive number */ + else if (sign) /* otherwise if the result is negative */ + t = ~t + 1; /* then return the twos complement (set if O = 0 above) */ #endif /* end of int64 support */ diff --git a/HP2100/hp2100_cpu4.c b/HP2100/hp2100_cpu4.c index ea294664..85dab53b 100644 --- a/HP2100/hp2100_cpu4.c +++ b/HP2100/hp2100_cpu4.c @@ -1,6 +1,6 @@ /* hp2100_cpu4.c: HP 1000 FPP/SIS - Copyright (c) 2006-2012, J. David Bryan + Copyright (c) 2006-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ CPU4 Floating Point Processor and Scientific Instruction Set + 24-Dec-14 JDB Added casts for explicit downward conversions 09-May-12 JDB Separated assignments from conditional expressions 06-Feb-12 JDB Added OPSIZE casts to fp_accum calls in .FPWR/.TPWR 11-Sep-08 JDB Moved microcode function prototypes to hp2100_cpu1.h @@ -312,7 +313,7 @@ switch (entry) { /* decode IR<6:0> */ case 0007: /* [stk] 105007 (OP_A) */ O = 0; /* clear overflow */ - stk_ptr = PC; /* save ptr to next buf */ + stk_ptr = (uint16) PC; /* save ptr to next buf */ rtn_addr = op[0].word; /* save return address */ while (TRUE) { @@ -709,7 +710,7 @@ switch (entry) { /* decode IR<3:0> */ op[1].fpk[1] = op[1].fpk[1] | 2; /* set "exponent" to 1 */ } - op[2].fpk[0] = exponent; + op[2].fpk[0] = (uint16) exponent; fp_exec (0120, &op[3], op[2], NOP); /* op3 = FLT(exponent) */ fp_exec (0020, &op[4], op[1], plus_1); /* op4 = op1 - 1.0 */ diff --git a/HP2100/hp2100_cpu5.c b/HP2100/hp2100_cpu5.c index 5a72e75a..89078acb 100644 --- a/HP2100/hp2100_cpu5.c +++ b/HP2100/hp2100_cpu5.c @@ -1,7 +1,7 @@ /* hp2100_cpu5.c: HP 1000 RTE-6/VM VMA and RTE-IV EMA instructions Copyright (c) 2007-2008, Holger Veit - Copyright (c) 2006-2012, J. David Bryan + Copyright (c) 2006-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,7 @@ CPU5 RTE-6/VM and RTE-IV firmware option instructions + 24-Dec-14 JDB Added casts for explicit downward conversions 17-Dec-12 JDB Fixed cpu_vma_mapte to return FALSE if not a VMA program 09-May-12 JDB Separated assignments from conditional expressions 23-Mar-12 JDB Added sign extension for dim count in "cpu_ema_resolve" @@ -389,8 +390,11 @@ if (debug) O = 0; /* clear overflow */ if (ptr & 0x80000000) { /* is it a local reference? */ ptrl = ptr & VAMASK; - if ((ptr&I_IA) && (reason = vma_resolve (ReadW (ptrl), &ptrl, debug))) - return reason; /* yes, resolve indirect ref */ + if (ptr&I_IA) { + reason = vma_resolve (ReadW (ptrl), &ptrl, debug); + if (reason) + return reason; /* yes, resolve indirect ref */ + } BR = ptrl & VAMASK; /* address is local */ AR = (ptr >> 16) & DMASK; if (debug) @@ -418,7 +422,7 @@ if (!p30) /* matched suit for 1st page * must be in idx 0 of PTE */ if (pgidx==01777) { /* suit switch situation */ pgidx = 0; /* select correct idx 0 */ - suit = pagid+1; /* suit needs increment */ + suit = (uint16) (pagid + 1); /* suit needs increment */ if (suit==0) { /* is it page 65536? */ offset += 02000; /* adjust to 2nd page */ suit = NILPAGE; @@ -447,8 +451,8 @@ else { return cpu_vma_fault(pagid+1,page31,31,ptepg,faultab,faultpc,debug); } -AR = pagid; /* return pagid in A */ -BR = page30+offset; /* mapped address in B */ +AR = (uint16) pagid; /* return pagid in A */ +BR = (uint16) (page30 + offset); /* mapped address in B */ if (debug) fprintf(sim_deb,">>CPU VMA: cpu_vma_lbp: map done AR=%06o BR=%o6o\n",AR,BR); return SCPE_OK; @@ -612,7 +616,8 @@ if (ndim == 0) { /* no dimensions: */ accu = 0; while (ndim-- > 0) { MA = ReadW(atbl++); /* get addr of subscript */ - if ((reason = resolve (MA, &MA, intrq))) /* and resolve it */ + reason = resolve (MA, &MA, intrq); /* and resolve it */ + if (reason) return reason; din = ReadOp(MA,ij); /* get actual subscript value */ ax = ij==in_d ? INT32(din.dword) : INT16(din.word); @@ -647,6 +652,7 @@ t_stat cpu_rte_vma (uint32 IR, uint32 intrq) t_stat reason = SCPE_OK; OPS op; OP_PAT pattern; +uint16 t16; uint32 entry,t32,ndim; uint32 dtbl,atbl; /* descriptor table ptr, actual args ptr */ OP dop0,dop1; @@ -691,9 +697,9 @@ switch (entry) { /* decode IR<3:0> */ break; case 003: /* [swap] 105243 (OP_N) */ - t32 = AR; /* swap A and B registers */ + t16 = AR; /* swap A and B registers */ AR = BR; - BR = t32; + BR = t16; break; case 004: /* [---] 105244 (OP_N) */ @@ -718,10 +724,12 @@ switch (entry) { /* decode IR<3:0> */ case 010: /* .IMAP 105250 (OP_A) */ dtbl = op[0].word; atbl = PC; - if ((reason = cpu_vma_ijmar(in_s,dtbl,atbl,&ndim,intrq,debug))) /* calc the virt address to AB */ + reason = cpu_vma_ijmar(in_s,dtbl,atbl,&ndim,intrq,debug); /* calc the virt address to AB */ + if (reason) return reason; t32 = (AR << 16) | (BR & DMASK); - if ((reason = cpu_vma_lbp(t32,0,PC-2,intrq,debug))) + reason = cpu_vma_lbp(t32,0,PC-2,intrq,debug); + if (reason) return reason; if (PC==pcsave) PC = (PC+ndim) & VAMASK; /* adjust PC: skip ndim subscript words */ @@ -736,10 +744,12 @@ switch (entry) { /* decode IR<3:0> */ case 012: /* .JMAP 105252 (OP_A) */ dtbl = op[0].word; atbl = PC; - if ((reason = cpu_vma_ijmar(in_d,dtbl,atbl,&ndim,intrq,debug))) /* calc the virtual address to AB */ + reason = cpu_vma_ijmar(in_d,dtbl,atbl,&ndim,intrq,debug); /* calc the virtual address to AB */ + if (reason) return reason; t32 = (AR << 16) | (BR & DMASK); - if ((reason = cpu_vma_lbp(t32,0,PC-2,intrq,debug))) + reason = cpu_vma_lbp(t32,0,PC-2,intrq,debug); + if (reason) return reason; if (PC==pcsave) PC = (PC + ndim) & VAMASK; /* adjust PC: skip ndim subscript dword ptr */ @@ -1026,7 +1036,7 @@ YR = ReadW(MA); WriteW(vout++, MA); vin++; /* copy address of N */ if (imax==0) goto easy; /* easy case */ -AR = k / imax; AR++; /* calculate K/IMAX */ +AR = (uint16) (k / imax); AR++; /* calculate K/IMAX */ if (negflag) goto hard; /* had a negative index? */ if (YR > AR) goto hard; @@ -1192,7 +1202,7 @@ if ((idext0 & 0100000) || /* was nonstd MSEG? */ e->npgs = msnum==e->msegno ? lastpgs : e->msegsz; /* for last MSEG, only map available pgs */ if (!cpu_ema_mmap01(e)) return FALSE; /* map npgs pages at ipgs */ } -BR = e->mseg + e->msoff; /* return address of element */ +BR = (uint16) (e->mseg + e->msoff); /* return address of element */ return TRUE; /* and everything done */ } @@ -1246,7 +1256,7 @@ if (npgs < e->msegsz) { e->mseg = mseg; /* logical stat of MSEG */ if (!cpu_ema_emat(e)) goto em16; /* do a std mapping */ } else { - BR = mseg + e->offs; /* logical start of buffer */ + BR = (uint16) (mseg + e->offs); /* logical start of buffer */ e->npgs = bufpgs; /* S5 # pgs required */ e->ipgs = e->pgoff; /* S6 page offset to reqd pg */ if (!cpu_ema_mmap02(e)) goto em16; /* do nonstd mapping */ @@ -1325,7 +1335,7 @@ if (xidex) { /* is EMA declared? */ idext0 = ReadWA(xidex+0) | 0100000; /* set NS flag in id extension */ WriteIO(xidex+0, idext0, SMAP); /* save back value */ AR = 0; /* was successful */ - BR = mseg + offs; /* calculate log address */ + BR = (uint16) (mseg + offs); /* calculate log address */ (*rtn)++; /* return via good exit */ return SCPE_OK; } @@ -1348,7 +1358,7 @@ while (ndim > 0) { if (sum & 0xffff8000) goto em15; /* overflow? */ ndim--; } -BR = abase + sum; /* add displacement */ +BR = (uint16) (abase + sum); /* add displacement */ (*rtn)++; /* return via good exit */ return SCPE_OK; diff --git a/HP2100/hp2100_cpu6.c b/HP2100/hp2100_cpu6.c index c00689d6..1f056046 100644 --- a/HP2100/hp2100_cpu6.c +++ b/HP2100/hp2100_cpu6.c @@ -1,6 +1,6 @@ /* hp2100_cpu6.c: HP 1000 RTE-6/VM OS instructions - Copyright (c) 2006-2013, J. David Bryan + Copyright (c) 2006-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ CPU6 RTE-6/VM OS instructions + 24-Dec-14 JDB Added casts for explicit downward conversions 18-Mar-13 JDB Use MP abort handler declaration in hp2100_cpu.h 09-May-12 JDB Separated assignments from conditional expressions 29-Oct-10 JDB DMA channels renamed from 0,1 to 1,2 to match documentation @@ -318,7 +319,7 @@ return reason; the table. */ -uint32 cpu_get_intbl (uint32 select_code) +static uint16 cpu_get_intbl (uint32 select_code) { uint16 interrupt_table; /* interrupt table (starts with SC 06) */ uint16 table_length; /* length of interrupt table */ @@ -379,7 +380,7 @@ t_stat cpu_rte_os (uint32 IR, uint32 intrq, uint32 iotrap) t_stat reason = SCPE_OK; OPS op; OP_PAT pattern; -uint32 entry, count, cp, sa, da, i, ma; +uint32 entry, count, cp, sa, da, i, ma, eqta; uint16 vectors, save_area, priv_fence, eoreg, eqt, key; char test[6], target[6]; jmp_buf mp_handler; @@ -675,12 +676,14 @@ switch (entry) { /* decode IR<3:0> */ eqt = ReadW (eqt1); /* get addr of EQT1 */ if (AR != eqt) { /* already set up? */ - for (eqt = eqt1; eqt <= eqt11; eqt++) /* init EQT1-EQT11 */ - WriteW (eqt & VAMASK, (AR++ & DMASK)); - for (eqt = eqt12; eqt <= eqt15; eqt++) /* init EQT12-EQT15 */ - WriteW (eqt & VAMASK, (AR++ & DMASK)); /* (not contig with EQT1-11) */ + for (eqta = eqt1; eqta <= eqt11; eqta++) /* init EQT1-EQT11 */ + WriteW (eqta, AR++ & DMASK); + for (eqta = eqt12; eqta <= eqt15; eqta++) /* init EQT12-EQT15 */ + WriteW (eqta, AR++ & DMASK); /* (not contig with EQT1-11) */ } + AR = AR & DMASK; /* ensure wraparound */ + if (debug_print) /* debugging? */ fprintf (sim_deb, /* print return registers */ ", A = %06o, EQT1 = %06o", AR, eqt); @@ -724,7 +727,7 @@ switch (entry) { /* decode IR<3:0> */ } if (entry == 016) /* call was .ENTC? */ - AR = sa; /* set A to return address */ + AR = (uint16) sa; /* set A to return address */ } break; diff --git a/HP2100/hp2100_cpu7.c b/HP2100/hp2100_cpu7.c index 2c6606d2..4f4cbb78 100644 --- a/HP2100/hp2100_cpu7.c +++ b/HP2100/hp2100_cpu7.c @@ -1,7 +1,7 @@ /* hp2100_cpu7.c: HP 1000 VIS and SIGNAL/1000 microcode Copyright (c) 2008, Holger Veit - Copyright (c) 2006-2013, J. David Bryan + Copyright (c) 2006-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,7 @@ CPU7 Vector Instruction Set and SIGNAL firmware + 24-Dec-14 JDB Added casts for explicit downward conversions 18-Mar-13 JDB Moved EMA helper declarations to hp2100_cpu1.h 09-May-12 JDB Separated assignments from conditional expressions 06-Feb-12 JDB Corrected "opsize" parameter type in vis_abs @@ -150,7 +151,7 @@ int16 ix1 = INT16(op[2].word) * delta; uint32 v2addr = op[3].word; int16 ix2 = INT16(op[4].word) * delta; int16 i, n = INT16(op[5].word); -uint32 fpuop = (subcode & 060) | (opsize==fp_f ? 0 : 2); +uint16 fpuop = (uint16) (subcode & 060) | (opsize==fp_f ? 0 : 2); if (n <= 0) return; for (i=0; ifpk[1] = (in.fpk[1] & 0177400) | (in.fpk[3] & 0377); static void vis_vsmnm(OPS op,OPSIZE opsize,t_bool doabs) { -uint32 fpuop; +uint16 fpuop; OP v1,sumnrm = zero; int16 delta = opsize==fp_f ? 2 : 4; uint32 saddr = op[0].word; @@ -536,7 +537,7 @@ static const OP_PAT op_signal[16] = { }; /* complex addition helper */ -static void sig_caddsub(uint32 addsub,OPS op) +static void sig_caddsub(uint16 addsub,OPS op) { OP a,b,c,d,p1,p2; @@ -617,7 +618,7 @@ WriteOp(im+rev, v1i, fp_f); } /* helper for PRSCR/UNSCR */ -static OP sig_scadd(uint32 oper,t_bool addh, OP a, OP b) +static OP sig_scadd(uint16 oper,t_bool addh, OP a, OP b) { OP r; static const OP plus_half = { { 0040000, 0000000 } }; /* DEC +0.5 */ diff --git a/HP2100/hp2100_defs.h b/HP2100/hp2100_defs.h index ca5e7031..4713a6ff 100644 --- a/HP2100/hp2100_defs.h +++ b/HP2100/hp2100_defs.h @@ -23,7 +23,8 @@ be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Robert M Supnik. - 15-Dec-14 JDB Added "-Wunused-const-variable" to the suppression pragmas + 30-Dec-14 JDB Added S-register parameters to ibl_copy, more IBL constants + 28-Dec-14 JDB Changed suppression from #pragma GCC to #pragma clang 05-Feb-13 JDB Added declaration for hp_fprint_stopped 18-Mar-13 JDB Added "-Wdangling-else" to the suppression pragmas Removed redundant extern declarations @@ -79,15 +80,18 @@ #include "sim_defs.h" /* simulator defns */ -/* Required to quell clang precedence warnings */ +/* The following pragmas quell clang warnings that are on by default but should + not be, in my opinion. They warn about the use of perfectly valid code and + require the addition of redundant parentheses and braces to silence them. + Rather than clutter up the code with scores of extra symbols that, in my + view, make the code harder to read and maintain, I elect to suppress these + warnings. +*/ -#if defined (__GNUC__) -#pragma GCC diagnostic ignored "-Wunknown-pragmas" -#pragma GCC diagnostic ignored "-Wpragmas" -#pragma GCC diagnostic ignored "-Wlogical-op-parentheses" -#pragma GCC diagnostic ignored "-Wbitwise-op-parentheses" -#pragma GCC diagnostic ignored "-Wdangling-else" -#pragma GCC diagnostic ignored "-Wunused-const-variable" +#if defined (__clang__) +#pragma clang diagnostic ignored "-Wlogical-op-parentheses" +#pragma clang diagnostic ignored "-Wbitwise-op-parentheses" +#pragma clang diagnostic ignored "-Wdangling-else" #endif @@ -218,6 +222,12 @@ typedef enum { INITIAL, SERVICE } POLLMODE; /* poll synchronization #define IBL_DPC (IBL_LNT - 2) /* DMA ctrl word */ #define IBL_END (IBL_LNT - 1) /* last location */ +#define IBL_S_CLR 0000000 /* ibl_copy mask to clear the S register */ +#define IBL_S_NOCLR 0177777 /* ibl_copy mask to preserve the S register */ +#define IBL_S_NOSET 0000000 /* ibl_copy mask to preserve the S register */ + +#define IBL_SET_SC(s) ((s) << IBL_V_DEV) /* position the select code in the S register */ + typedef uint16 BOOT_ROM [IBL_LNT]; /* boot ROM data */ @@ -457,12 +467,11 @@ struct dib { /* Device information bl /* CPU state */ -extern uint32 SR; /* S register (for IBL) */ extern uint32 dev_prl [2], dev_irq [2], dev_srq [2]; /* I/O signal vectors */ /* CPU functions */ -extern t_stat ibl_copy (const BOOT_ROM rom, int32 dev); +extern t_stat ibl_copy (const BOOT_ROM rom, int32 dev, uint32 sr_clear, uint32 sr_set); extern void hp_enbdis_pair (DEVICE *ccp, DEVICE *dcp); /* System functions */ diff --git a/HP2100/hp2100_di.c b/HP2100/hp2100_di.c index 98cc4ef0..5ff94b43 100644 --- a/HP2100/hp2100_di.c +++ b/HP2100/hp2100_di.c @@ -1,6 +1,6 @@ /* hp2100_di.c: HP 12821A HP-IB Disc Interface simulator - Copyright (c) 2010-2012, J. David Bryan + Copyright (c) 2010-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,8 @@ DI 12821A Disc Interface + 24-Dec-14 JDB Added casts for explicit downward conversions + Removed redundant global declarations 13-Feb-12 JDB First release 15-Dec-11 JDB Added dummy DC device for diagnostics 09-Oct-10 JDB Created DI simulation @@ -191,24 +193,6 @@ typedef enum { DI_STATE di [card_count]; /* per-card state */ -/* Disc interface global VM routines */ - -IOHANDLER di_io; -t_stat di_reset (DEVICE *dptr); - -/* Disc interface global SCP routines */ - -t_stat di_set_address (UNIT *uptr, int32 value, char *cptr, void *desc); -t_stat di_show_address (FILE *st, UNIT *uptr, int32 value, void *desc); -t_stat di_set_cable (UNIT *uptr, int32 value, char *cptr, void *desc); -t_stat di_show_cable (FILE *st, UNIT *uptr, int32 value, void *desc); - -/* Disc interface global bus routines */ - -t_bool di_bus_source (CARD_ID card, uint8 data); -void di_bus_control (CARD_ID card, uint32 unit, uint8 assert, uint8 deny); -void di_poll_response (CARD_ID card, uint32 unit, FLIP_FLOP response); - /* Disc interface local bus routines */ static t_bool di_bus_accept (CARD_ID card, uint8 data); @@ -831,7 +815,7 @@ DEVICE *dptr = (DEVICE *) desc; if (cptr == NULL) /* if the address is not given */ return SCPE_ARG; /* report a missing argument */ -new_address = get_uint (cptr, 10, 7, &status); /* parse the address value */ +new_address = (uint32) get_uint (cptr, 10, 7, &status); /* parse the address value */ if (status == SCPE_OK) { /* is the parse OK? */ if (value) /* are we setting the card address? */ @@ -1868,11 +1852,11 @@ if (di_card->cntl_register & CNTL_TALK) /* is the card talking? if (di_card->cntl_register & CNTL_CIC) /* is the card the controller in charge? */ di_card->bus_cntl = /* assert or deny the ATN bus line */ di_card->bus_cntl & ~BUS_ATN /* from the ATN tag value */ - | (tag & TAG_ATN) >> BUS_SHIFT; + | (uint8) ((tag & TAG_ATN) >> BUS_SHIFT); di_card->bus_cntl = /* assert or deny the EOI bus line */ di_card->bus_cntl & ~BUS_EOI /* from the EOI tag value */ - | (tag & TAG_EOI) >> BUS_SHIFT; + | (uint8) ((tag & TAG_EOI) >> BUS_SHIFT); } return (uint16) data; /* return the data value */ diff --git a/HP2100/hp2100_di.h b/HP2100/hp2100_di.h index 08171b21..69d5f1df 100644 --- a/HP2100/hp2100_di.h +++ b/HP2100/hp2100_di.h @@ -144,8 +144,8 @@ typedef enum { #define GET_UPPER(w) (uint8) (((w) & UPPER_BYTE) >> BYTE_SHIFT) #define GET_LOWER(w) (uint8) ((w) & LOWER_BYTE) -#define SET_UPPER(b) ((b) << BYTE_SHIFT) -#define SET_LOWER(b) (b) +#define SET_UPPER(b) (uint16) ((b) << BYTE_SHIFT) +#define SET_LOWER(b) (uint16) (b) #define SET_BOTH(b) (SET_UPPER (b) | SET_LOWER (b)) typedef enum { diff --git a/HP2100/hp2100_di_da.c b/HP2100/hp2100_di_da.c index a3d73fdd..9e4278ff 100644 --- a/HP2100/hp2100_di_da.c +++ b/HP2100/hp2100_di_da.c @@ -1,6 +1,6 @@ /* hp2100_di_da.c: HP 12821A HP-IB Disc Interface simulator for Amigo disc drives - Copyright (c) 2011-2012, J. David Bryan + Copyright (c) 2011-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,9 @@ DA 12821A Disc Interface with Amigo disc drives + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Use T_ADDR_FMT with t_addr values for 64-bit compatibility + Removed redundant global declarations 24-Oct-12 JDB Changed CNTLR_OPCODE to title case to avoid name clash 07-May-12 JDB Cancel the intersector delay if an untalk is received 29-Mar-12 JDB First release @@ -462,21 +465,14 @@ static CNTLR_VARS icd_cntlr [DA_UNITS] = /* ICD controllers: */ /* Amigo disc global VM routines */ -t_stat da_service (UNIT *uptr); t_stat da_reset (DEVICE *dptr); t_stat da_attach (UNIT *uptr, char *cptr); t_stat da_detach (UNIT *uptr); -t_stat da_boot (int32 unitno, DEVICE *dptr); /* Amigo disc global SCP routines */ t_stat da_load_unload (UNIT *uptr, int32 value, char *cptr, void *desc); -/* Amigo disc global bus routines */ - -t_bool da_bus_accept (uint32 unit, uint8 data); -void da_bus_respond (CARD_ID card, uint32 unit, uint8 new_cntl); - /* Amigo disc local utility routines */ static t_bool start_command (uint32 unit); @@ -1214,13 +1210,12 @@ t_stat da_boot (int32 unitno, DEVICE *dptr) if (GET_BUSADR (da_unit [unitno].flags) != 0) /* booting is supported on bus address 0 only */ return SCPE_NOFNC; /* report "Command not allowed" if attempted */ -if (ibl_copy (da_rom, da_dib.select_code)) /* copy the boot ROM to memory and configure */ - return SCPE_IERR; /* return an internal error if the copy failed */ - -SR = SR & (IBL_OPT | IBL_DS_HEAD) /* set S to a reasonable value */ - | IBL_DS | IBL_MAN | (da_dib.select_code << IBL_V_DEV); /* before boot execution */ - -return SCPE_OK; +if (ibl_copy (da_rom, da_dib.select_code, /* copy the boot ROM to memory and configure */ + IBL_OPT | IBL_DS_HEAD, /* the S register accordingly */ + IBL_DS | IBL_MAN | IBL_SET_SC (da_dib.select_code))) + return SCPE_IERR; /* return an internal error if the copy failed */ +else + return SCPE_OK; } @@ -1791,7 +1786,7 @@ if (da_unit [unit].wait > 0) /* was service requested if (initiated && DEBUG_PRI (da_dev, DEB_RWSC)) if (if_command [unit] == disc_command) - fprintf (sim_deb, ">>DA rwsc: Unit %d position %d %s disc command initiated\n", + fprintf (sim_deb, ">>DA rwsc: Unit %d position %" T_ADDR_FMT "d %s disc command initiated\n", unit, da_unit [unit].pos, dl_opcode_name (ICD, icd_cntlr [unit].opcode)); else fprintf (sim_deb, ">>DA rwsc: Unit %d %s command initiated\n", diff --git a/HP2100/hp2100_dp.c b/HP2100/hp2100_dp.c index 40614207..5b44f611 100644 --- a/HP2100/hp2100_dp.c +++ b/HP2100/hp2100_dp.c @@ -1,6 +1,6 @@ /* hp2100_dp.c: HP 2100 12557A/13210A disk simulator - Copyright (c) 1993-2012, Robert M. Supnik + Copyright (c) 1993-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,8 @@ DP 12557A 2871 disk subsystem 13210A 7900 disk subsystem + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Added casts for explicit downward conversions 18-Dec-12 MP Now calls sim_activate_time to get remaining seek time 09-May-12 JDB Separated assignments from conditional expressions 10-Feb-12 JDB Deprecated DEVNO in favor of SC @@ -575,7 +577,8 @@ while (working_set) { data = 0; for (i = 0; i < DP_NUMDRV; i++) /* form attention register value */ - if (dpc_sta[i] & STA_ATN) data = data | (1 << i); + if (dpc_sta[i] & STA_ATN) + data = data | (uint16) (1 << i); stat_data = IORETURN (SCPE_OK, data); /* merge in return status */ break; @@ -950,7 +953,7 @@ switch (uptr->FNC) { /* case function */ break; /* done */ } } - dpxb[dp_ptr++] = dpd_wval? dpd_obuf: 0; /* store word/fill */ + dpxb[dp_ptr++] = dpd_wval ? (uint16) dpd_obuf : 0; /* store word/fill */ dpd_wval = 0; /* clr data valid */ if (dp_ptr >= DP_NUMWD) { /* buffer full? */ da = GETDA (dpc_rarc, dpc_rarh, dpc_rars); /* calc disk addr */ @@ -1181,12 +1184,15 @@ const BOOT_ROM dp_rom = { t_stat dpc_boot (int32 unitno, DEVICE *dptr) { -int32 dev; +const int32 dev = dpd_dib.select_code; /* data chan select code */ -if (unitno != 0) return SCPE_NOFNC; /* only unit 0 */ -dev = dpd_dib.select_code; /* get data chan dev */ -if (ibl_copy (dp_rom, dev)) return SCPE_IERR; /* copy boot to memory */ -SR = (SR & IBL_OPT) | IBL_DP | (dev << IBL_V_DEV); /* set SR */ -if (sim_switches & SWMASK ('R')) SR = SR | IBL_DP_REM; /* boot from removable? */ -return SCPE_OK; +if (unitno != 0) /* boot supported on drive unit 0 only */ + return SCPE_NOFNC; /* report "Command not allowed" if attempted */ + +if (ibl_copy (dp_rom, dev, IBL_OPT, /* copy the boot ROM to memory and configure */ + IBL_DP | IBL_SET_SC (dev) /* the S register accordingly */ + | (sim_switches & SWMASK ('R') ? IBL_DP_REM : 0))) + return SCPE_IERR; /* return an internal error if the copy failed */ +else + return SCPE_OK; } diff --git a/HP2100/hp2100_dq.c b/HP2100/hp2100_dq.c index 11feafb7..e435270c 100644 --- a/HP2100/hp2100_dq.c +++ b/HP2100/hp2100_dq.c @@ -1,7 +1,7 @@ /* hp2100_dq.c: HP 2100 12565A disk simulator Copyright (c) 1993-2006, Bill McDermith - Copyright (c) 2004-2012 J. David Bryan + Copyright (c) 2004-2014 J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,8 @@ DQ 12565A 2883 disk system + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Added casts for explicit downward conversions 18-Dec-12 MP Now calls sim_activate_time to get remaining seek time 09-May-12 JDB Separated assignments from conditional expressions 10-Feb-12 JDB Deprecated DEVNO in favor of SC @@ -786,12 +788,12 @@ switch (uptr->FNC) { /* case function */ break; } } - dqxb[dq_ptr++] = dqd_wval? dqd_obuf: 0; /* store word/fill */ - dqd_wval = 0; /* clr data valid */ - if (dq_ptr >= DQ_NUMWD) { /* buffer full? */ - da = GETDA (dqc_rarc, dqc_rarh, dqc_rars); /* calc disk addr */ - dqc_rars = (dqc_rars + 1) % DQ_NUMSC; /* incr sector */ - if (dqc_rars == 0) /* wrap? incr head */ + dqxb[dq_ptr++] = dqd_wval ? (uint16) dqd_obuf : 0; /* store word/fill */ + dqd_wval = 0; /* clr data valid */ + if (dq_ptr >= DQ_NUMWD) { /* buffer full? */ + da = GETDA (dqc_rarc, dqc_rarh, dqc_rars); /* calc disk addr */ + dqc_rars = (dqc_rars + 1) % DQ_NUMSC; /* incr sector */ + if (dqc_rars == 0) /* wrap? incr head */ dqc_uhed[drv] = dqc_rarh = dqc_rarh + 1; err = fseek (uptr->fileref, da * sizeof (int16), SEEK_SET); if (err) @@ -962,11 +964,14 @@ const BOOT_ROM dq_rom = { t_stat dqc_boot (int32 unitno, DEVICE *dptr) { -int32 dev; +const int32 dev = dqd_dib.select_code; /* data chan select code */ -if (unitno != 0) return SCPE_NOFNC; /* only unit 0 */ -dev = dqd_dib.select_code; /* get data chan dev */ -if (ibl_copy (dq_rom, dev)) return SCPE_IERR; /* copy boot to memory */ -SR = (SR & IBL_OPT) | IBL_DQ | (dev << IBL_V_DEV); /* set SR */ -return SCPE_OK; +if (unitno != 0) /* boot supported on drive unit 0 only */ + return SCPE_NOFNC; /* report "Command not allowed" if attempted */ + +if (ibl_copy (dq_rom, dev, IBL_OPT, /* copy the boot ROM to memory and configure */ + IBL_DQ | IBL_SET_SC (dev))) /* the S register accordingly */ + return SCPE_IERR; /* return an internal error if the copy failed */ +else + return SCPE_OK; } diff --git a/HP2100/hp2100_dr.c b/HP2100/hp2100_dr.c index 69c8b7f2..f9489ddb 100644 --- a/HP2100/hp2100_dr.c +++ b/HP2100/hp2100_dr.c @@ -1,6 +1,6 @@ /* hp2100_dr.c: HP 2100 12606B/12610B fixed head disk/drum simulator - Copyright (c) 1993-2012, Robert M. Supnik + Copyright (c) 1993-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,8 @@ DR 12606B 2770/2771 fixed head disk 12610B 2773/2774/2775 drum + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Added casts for explicit downward conversions 10-Feb-12 JDB Deprecated DEVNO in favor of SC 28-Mar-11 JDB Tidied up signal handling 26-Oct-10 JDB Changed I/O signal handler for revised signal model @@ -466,14 +468,14 @@ while (working_set) { case ioIOI: /* I/O data input */ - data = drc_sta; /* static bits */ + data = (uint16) drc_sta; /* static bits */ if (!(drc_unit.flags & UNIT_PROT) || /* not protected? */ (CW_GETTRK(drc_cw) >= drc_pcount)) /* or not in range? */ data = data | DRS_WEN; /* set wrt enb status */ if (drc_unit.flags & UNIT_ATT) { /* attached? */ - data = data | (dr_seccntr (sim_gtime()) << DRS_V_NS) | DRS_RDY; + data = data | (uint16) (dr_seccntr (sim_gtime()) << DRS_V_NS) | DRS_RDY; if (sim_is_active (&drc_unit)) /* op in progress? */ data = data | DRS_BSY; if (CALC_SCP (sim_gtime())) /* SCP ff set? */ @@ -528,7 +530,7 @@ drc_run = 1; /* set run ff */ if (drc_cw & CW_WR) { /* write? */ if ((da < uptr->capac) && (sec < DR_NUMSC)) { - bptr[da + drd_ptr] = drd_obuf; + bptr[da + drd_ptr] = (uint16) drd_obuf; if (((uint32) (da + drd_ptr)) >= uptr->hwmark) uptr->hwmark = da + drd_ptr + 1; } @@ -540,7 +542,7 @@ if (drc_cw & CW_WR) { /* write? */ else { /* done */ if (drd_ptr) /* need to fill? */ for ( ; drd_ptr < DR_NUMWD; drd_ptr++) - bptr[da + drd_ptr] = drd_obuf; /* fill with last word */ + bptr[da + drd_ptr] = (uint16) drd_obuf; /* fill with last word */ if (!(drc_unit.flags & UNIT_DRUM)) /* disk? */ drc_sta = drc_sta | DRS_PER; /* parity bit sets on write */ drc_run = 0; /* clear run ff */ @@ -735,13 +737,15 @@ t_stat drc_boot (int32 unitno, DEVICE *dptr) { const int32 dev = drd_dib.select_code; /* data chan select code */ -if (unitno != 0) /* only unit 0 */ - return SCPE_NOFNC; -if (ibl_copy (dr_rom, dev)) /* copy boot to memory */ - return SCPE_IERR; +if (unitno != 0) /* boot supported on drive unit 0 only */ + return SCPE_NOFNC; /* report "Command not allowed" if attempted */ + +if (ibl_copy (dr_rom, dev, IBL_S_NOCLR, IBL_S_NOSET)) /* copy the boot ROM to memory and configure */ + return SCPE_IERR; /* return an internal error if the copy failed */ WritePW (PC + IBL_DPC, dr_rom [IBL_DPC]); /* restore overwritten word */ WritePW (PC + IBL_END, dr_rom [IBL_END]); /* restore overwritten word */ PC = PC + BOOT_START; /* correct starting address */ + return SCPE_OK; } diff --git a/HP2100/hp2100_ds.c b/HP2100/hp2100_ds.c index 974bc80a..dea160b6 100644 --- a/HP2100/hp2100_ds.c +++ b/HP2100/hp2100_ds.c @@ -1,7 +1,7 @@ /* hp2100_ds.c: HP 13037D/13175D disc controller/interface simulator Copyright (c) 2004-2012, Robert M. Supnik - Copyright (c) 2012-2013 J. David Bryan + Copyright (c) 2012-2014 J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,8 @@ DS 13037D/13175D disc controller/interface + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Use T_ADDR_FMT with t_addr values for 64-bit compatibility 18-Mar-13 JDB Fixed poll_drives definition to match declaration 24-Oct-12 JDB Changed CNTLR_OPCODE to title case to avoid name clash 29-Mar-12 JDB Rewritten to use the MAC/ICD disc controller library @@ -1165,16 +1167,15 @@ const BOOT_ROM ds_rom = { t_stat ds_boot (int32 unitno, DEVICE *dptr) { -if (unitno != 0) /* boot supported on drive unit 0 only */ - return SCPE_NOFNC; /* report "Command not allowed" if attempted */ +if (unitno != 0) /* boot supported on drive unit 0 only */ + return SCPE_NOFNC; /* report "Command not allowed" if attempted */ -if (ibl_copy (ds_rom, ds_dib.select_code)) /* copy the boot ROM to memory and configure */ - return SCPE_IERR; /* return an internal error if the copy failed */ - -SR = SR & (IBL_OPT | IBL_DS_HEAD) /* set S to a reasonable value */ - | IBL_DS | IBL_MAN | (ds_dib.select_code << IBL_V_DEV); /* before boot execution */ - -return SCPE_OK; +if (ibl_copy (ds_rom, ds_dib.select_code, /* copy the boot ROM to memory and configure */ + IBL_OPT | IBL_DS_HEAD, /* the S register accordingly */ + IBL_DS | IBL_MAN | IBL_SET_SC (ds_dib.select_code))) + return SCPE_IERR; /* return an internal error if the copy failed */ +else + return SCPE_OK; } @@ -1282,7 +1283,7 @@ if (uptr) { /* did the command start if (unit > DL_MAXDRIVE) fputs ("Controller ", sim_deb); else - fprintf (sim_deb, "Unit %d position %d ", unit, uptr->pos); + fprintf (sim_deb, "Unit %d position %" T_ADDR_FMT "d ", unit, uptr->pos); fprintf (sim_deb, "%s command initiated\n", dl_opcode_name (MAC, mac_cntlr.opcode)); diff --git a/HP2100/hp2100_fp.c b/HP2100/hp2100_fp.c index 10331795..c7125113 100644 --- a/HP2100/hp2100_fp.c +++ b/HP2100/hp2100_fp.c @@ -1,6 +1,6 @@ /* hp2100_fp.c: HP 2100 floating point instructions - Copyright (c) 2002-2008, Robert M. Supnik + Copyright (c) 2002-2015, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -23,6 +23,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Robert M Supnik. + 03-Jan-15 JDB Made the utility routines static 21-Jan-08 JDB Corrected fp_unpack mantissa high-word return (from Mark Pizzolato) 01-Dec-06 JDB Reworked FFP helpers for 1000-F support, deleted f_pwr2 @@ -124,11 +125,12 @@ struct ufp { /* unpacked fp */ #define FR_NEG(v) ((~(v) + 1) & DMASK32) -uint32 UnpackFP (struct ufp *fop, uint32 opnd); -void NegFP (struct ufp *fop); -void NormFP (struct ufp *fop); -uint32 PackFP (struct ufp *fop); -uint32 StoreFP (struct ufp *fop); +/* Utility routines */ + +static uint32 UnpackFP (struct ufp *fop, uint32 opnd); +static void NormFP (struct ufp *fop); +static uint32 PackFP (struct ufp *fop); +static uint32 StoreFP (struct ufp *fop); /* Floating to integer conversion */ @@ -240,7 +242,7 @@ return StoreFP (&res); /* store */ /* Floating point divide - reverse engineered from diagnostic */ -uint32 divx (uint32 ba, uint32 dvr, uint32 *rem) +static uint32 divx (uint32 ba, uint32 dvr, uint32 *rem) { int32 sdvd = 0, sdvr = 0; uint32 q, r; @@ -295,7 +297,7 @@ return StoreFP (&quo); /* store result */ /* Unpack operand */ -uint32 UnpackFP (struct ufp *fop, uint32 opnd) +static uint32 UnpackFP (struct ufp *fop, uint32 opnd) { fop->fr = opnd & FP_FR; /* get frac */ fop->exp = FP_GETEXP (opnd); /* get exp */ @@ -305,7 +307,7 @@ return FP_GETSIGN (opnd); /* return sign */ /* Normalize unpacked floating point number */ -void NormFP (struct ufp *fop) +static void NormFP (struct ufp *fop) { if (fop->fr) { /* any fraction? */ uint32 test = (fop->fr >> 1) & FP_NORM; @@ -320,7 +322,7 @@ return; /* Pack fp number */ -uint32 PackFP (struct ufp *fop) +static uint32 PackFP (struct ufp *fop) { return (fop->fr & FP_FR) | /* merge frac */ ((fop->exp & FP_M_EXP) << FP_V_EXP) | /* and exp */ @@ -329,7 +331,7 @@ return (fop->fr & FP_FR) | /* merge frac */ /* Round fp number, store, generate overflow */ -uint32 StoreFP (struct ufp *fop) +static uint32 StoreFP (struct ufp *fop) { uint32 sign, svfr, hi, ov = 0; diff --git a/HP2100/hp2100_fp1.c b/HP2100/hp2100_fp1.c index 20fdb0e5..413be34a 100644 --- a/HP2100/hp2100_fp1.c +++ b/HP2100/hp2100_fp1.c @@ -1,6 +1,6 @@ /* hp2100_fp1.c: HP 1000 multiple-precision floating point routines - Copyright (c) 2005-2013, J. David Bryan + Copyright (c) 2005-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -23,6 +23,8 @@ in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the author. + 24-Dec-14 JDB Added casts for explicit downward conversions + Changed fp_ucom return from uint32 to uint16 18-Mar-13 JDB Changed type of mantissa masks array to to unsigned 06-Feb-12 JDB Added missing precision on constant "one" in fp_trun 21-Jun-11 JDB Completed the comments for divide; no code changes @@ -510,8 +512,8 @@ uint8 exp; packed = pack_int (unpacked.mantissa, unpacked.precision); /* pack mantissa */ -exp = ((uint8) unpacked.exponent << FP_V_EXP) | /* rotate exponent */ - ((unpacked.exponent < 0) << FP_V_ESIGN); +exp = (uint8) (unpacked.exponent << FP_V_EXP | /* rotate exponent */ + (unpacked.exponent < 0) << FP_V_ESIGN); switch (unpacked.precision) { /* merge exponent into correct word */ @@ -527,8 +529,8 @@ switch (unpacked.precision) { /* merge exponent into c break; case fp_e: /* place in separate word */ - packed.fpk[4] = ((uint16) unpacked.exponent << FP_V_EXP) | - ((unpacked.exponent < 0) << FP_V_ESIGN); + packed.fpk[4] = (uint16) (unpacked.exponent << FP_V_EXP | + (unpacked.exponent < 0) << FP_V_ESIGN); break; case fp_a: /* no action for value in accum */ @@ -970,12 +972,12 @@ else { div = ah >> 2; /* ASR 2 to prevent overflow */ - pq1 = div / dh; /* form first partial quotient */ + pq1 = (int16) (div / dh); /* form first partial quotient */ div = ((div % dh) & ~1) << 15; /* ASR 1, move rem to upper */ - pq2 = div / dh; /* form second partial quotient */ + pq2 = (int16) (div / dh); /* form second partial quotient */ div = (uint16) dl << 13; /* move divisor LSB to upper, LSR 3 */ - cq = div / dh; /* form correction quotient */ + cq = (int16) (div / dh); /* form correction quotient */ cp = -cq * pq1; /* and correction product */ cp = (((cp >> 14) & ~3) + (int32) pq2) << 1; /* add corr prod and 2nd partial quo */ @@ -1392,7 +1394,7 @@ return 0; significant in the mantissa. */ -uint32 fp_ucom (OP *mantissa, OPSIZE precision) +uint16 fp_ucom (OP *mantissa, OPSIZE precision) { FPU unpacked; @@ -1401,7 +1403,7 @@ unpacked.exponent = 0; /* clear undefined expon unpacked.precision = precision; /* set precision */ complement (&unpacked); /* negate it */ *mantissa = pack_int (unpacked.mantissa, precision); /* replace mantissa */ -return (uint32) unpacked.exponent; /* return exponent increment */ +return (uint16) unpacked.exponent; /* return exponent increment */ } diff --git a/HP2100/hp2100_fp1.h b/HP2100/hp2100_fp1.h index 57914ca9..4de87a1e 100644 --- a/HP2100/hp2100_fp1.h +++ b/HP2100/hp2100_fp1.h @@ -1,6 +1,6 @@ /* hp2100_fp1.h: HP 2100/1000 multiple-precision floating point definitions - Copyright (c) 2005-2013, J. David Bryan + Copyright (c) 2005-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -23,6 +23,7 @@ in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the author. + 24-Dec-14 JDB Changed fp_ucom return from uint32 to uint16 14-Mar-13 MP Changed guard macro name to avoid reserved namespace 16-Oct-06 JDB Generalized FP calling sequences for F-Series 12-Oct-06 JDB Altered x_trun for F-Series FFP compatibility @@ -46,7 +47,7 @@ OP fp_accum (const OP *operand, OPSIZE precision); uint32 fp_pack (OP *result, OP mantissa, int32 exponent, OPSIZE precision); uint32 fp_nrpack (OP *result, OP mantissa, int32 exponent, OPSIZE precision); uint32 fp_unpack (OP *mantissa, int32 *exponent, OP packed, OPSIZE precision); -uint32 fp_ucom (OP *mantissa, OPSIZE precision); +uint16 fp_ucom (OP *mantissa, OPSIZE precision); uint32 fp_pcom (OP *packed, OPSIZE precision); uint32 fp_trun (OP *result, OP source, OPSIZE precision); uint32 fp_cvt (OP *result, OPSIZE source_precision, OPSIZE dest_precision); diff --git a/HP2100/hp2100_ipl.c b/HP2100/hp2100_ipl.c index 3d59ab0b..8d16be61 100644 --- a/HP2100/hp2100_ipl.c +++ b/HP2100/hp2100_ipl.c @@ -1,6 +1,6 @@ /* hp2100_ipl.c: HP 2000 interprocessor link simulator - Copyright (c) 2002-2012, Robert M Supnik + Copyright (c) 2002-2014, Robert M Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ IPLI, IPLO 12875A interprocessor link + 30-Dec-14 JDB Added S-register parameters to ibl_copy 12-Dec-12 MP Revised ipl_attach for new socket API 25-Oct-12 JDB Removed DEV_NET to allow restoration of listening ports 09-May-12 JDB Separated assignments from conditional expressions @@ -647,8 +648,8 @@ if (sim_switches & SWMASK ('W')) { /* wait? */ printf ("Waiting for connnection\n"); sim_os_sleep (1); /* sleep 1 sec */ } - if (t) - printf ("Connection established\n"); + if (t) /* if connected (set by "ipl_check_conn" above) */ + printf ("Connection established\n"); /* then report */ } return SCPE_OK; } @@ -789,8 +790,10 @@ t_stat ipl_boot (int32 unitno, DEVICE *dptr) const int32 devi = ipli_dib.select_code; const int32 devp = ptr_dib.select_code; -ibl_copy (ipl_rom, devi); /* copy bootstrap to memory */ -SR = (devi << IBL_V_DEV) | devp; /* set SR */ +if (ibl_copy (ipl_rom, devi, IBL_S_CLR, /* copy the boot ROM to memory and configure */ + IBL_SET_SC (devi) | devp)) /* the S register accordingly */ + return SCPE_IERR; /* return an internal error if the copy failed */ + WritePW (PC + MAX_BASE, (~PC + 1) & DMASK); /* fix ups */ WritePW (PC + IPL_PNTR, ipl_rom [IPL_PNTR] | PC); WritePW (PC + PTR_PNTR, ipl_rom [PTR_PNTR] | PC); diff --git a/HP2100/hp2100_mpx.c b/HP2100/hp2100_mpx.c index 08fdd260..e53271c9 100644 --- a/HP2100/hp2100_mpx.c +++ b/HP2100/hp2100_mpx.c @@ -1,6 +1,6 @@ /* hp2100_mpx.c: HP 12792C eight-channel asynchronous multiplexer simulator - Copyright (c) 2008-2013, J. David Bryan + Copyright (c) 2008-2014, J. David Bryan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ MPX 12792C 8-channel multiplexer card + 24-Dec-14 JDB Added casts for explicit downward conversions 10-Jan-13 MP Added DEV_MUX and additional DEVICE field values 28-Dec-12 JDB Allow direct attach to the poll unit only when restoring 10-Feb-12 JDB Deprecated DEVNO in favor of SC @@ -547,7 +548,7 @@ typedef enum { get, put } BUF_SELECT; /* buffer selector */ static const char *const io_op [] = { "read", /* operation names */ "write" }; -static const uint32 buf_size [] = { RD_BUF_SIZE, /* buffer sizes */ +static const uint16 buf_size [] = { RD_BUF_SIZE, /* buffer sizes */ WR_BUF_SIZE }; static uint32 emptying_flags [2]; /* buffer emptying flags [IO_OPER] */ @@ -581,7 +582,7 @@ static void buf_remove (IO_OPER rw, uint32 port); static void buf_term (IO_OPER rw, uint32 port, uint8 header); static void buf_free (IO_OPER rw, uint32 port); static void buf_cancel (IO_OPER rw, uint32 port, BUF_SELECT which); -static uint32 buf_len (IO_OPER rw, uint32 port, BUF_SELECT which); +static uint16 buf_len (IO_OPER rw, uint32 port, BUF_SELECT which); static uint32 buf_avail (IO_OPER rw, uint32 port); @@ -1101,8 +1102,8 @@ switch (mpx_cmd) { case UI_RDBUF_AVAIL: /* read buffer notification */ mpx_flags [mpx_port] &= ~FL_HAVEBUF; /* clear flag */ - mpx_ibuf = buf_get (ioread, mpx_port) << 8 | /* get header value and position */ - buf_len (ioread, mpx_port, get); /* and include buffer length */ + mpx_ibuf = (uint16) (buf_get (ioread, mpx_port) << 8 | /* get header value and position */ + buf_len (ioread, mpx_port, get)); /* and include buffer length */ if (mpx_flags [mpx_port] & FL_RDOVFLOW) { /* did a buffer overflow? */ mpx_ibuf = mpx_ibuf | RS_OVERFLOW; /* report it */ @@ -1184,9 +1185,9 @@ switch (mpx_cmd) { case CMD_SET_KEY: /* set port key and configuration */ port = GET_PORT (mpx_param); /* get target port number */ mpx_key [port] = (uint8) mpx_portkey; /* set port key */ - mpx_config [port] = mpx_param; /* set port configuration word */ + mpx_config [port] = (uint16) mpx_param; /* set port configuration word */ - svc_time = service_time (mpx_param); /* get service time for baud rate */ + svc_time = service_time (mpx_config [port]); /* get service time for baud rate */ if (svc_time) /* want to change? */ mpx_unit [port].wait = svc_time; /* set service time */ @@ -1199,7 +1200,7 @@ switch (mpx_cmd) { port = key_to_port (mpx_portkey); /* get port */ if (port >= 0) /* port defined? */ - mpx_rcvtype [port] = mpx_param; /* save port receive type */ + mpx_rcvtype [port] = (uint16) mpx_param; /* save port receive type */ break; @@ -1207,7 +1208,7 @@ switch (mpx_cmd) { port = key_to_port (mpx_portkey); /* get port */ if (port >= 0) /* port defined? */ - mpx_charcnt [port] = mpx_param; /* save port character count */ + mpx_charcnt [port] = (uint16) mpx_param; /* save port character count */ break; @@ -1378,13 +1379,13 @@ switch (mpx_state) { /* dispatch case idle: /* controller idle */ set_flag = FALSE; /* assume no UI */ - if (mpx_uicode) { /* unacknowledged UI? */ - if (mpx_uien == TRUE) { /* interrupts enabled? */ - mpx_port = GET_UIPORT (mpx_uicode); /* get port number */ - mpx_portkey = mpx_key [mpx_port]; /* get port key */ - mpx_ibuf = mpx_uicode & UI_REASON | mpx_portkey; /* report UI reason and port key */ - set_flag = TRUE; /* reissue host interrupt */ - mpx_uien = FALSE; /* disable UI */ + if (mpx_uicode) { /* unacknowledged UI? */ + if (mpx_uien == TRUE) { /* interrupts enabled? */ + mpx_port = GET_UIPORT (mpx_uicode); /* get port number */ + mpx_portkey = mpx_key [mpx_port]; /* get port key */ + mpx_ibuf = (uint16) (mpx_uicode & UI_REASON | mpx_portkey); /* report UI reason and port key */ + set_flag = TRUE; /* reissue host interrupt */ + mpx_uien = FALSE; /* disable UI */ if (DEBUG_PRI (mpx_dev, DEB_CMDS)) fprintf (sim_deb, ">>MPX cmds: Port %d key %d unsolicited interrupt reissued, " @@ -1415,12 +1416,12 @@ switch (mpx_state) { /* dispatch else if (mpx_flags [i] & FL_HAVEBUF) /* have a read buffer ready? */ mpx_uicode = UI_RDBUF_AVAIL; /* set UI reason */ - if (mpx_uicode) { /* UI to send? */ - mpx_port = i; /* set port number for Acknowledge */ - mpx_ibuf = mpx_uicode | mpx_portkey; /* merge UI reason and port key */ - mpx_uicode = mpx_uicode | mpx_port; /* save UI reason and port */ - set_flag = TRUE; /* interrupt host */ - mpx_uien = FALSE; /* disable UI */ + if (mpx_uicode) { /* UI to send? */ + mpx_port = i; /* set port number for Acknowledge */ + mpx_ibuf = (uint16) (mpx_uicode | mpx_portkey); /* merge UI reason and port key */ + mpx_uicode = mpx_uicode | mpx_port; /* save UI reason and port */ + set_flag = TRUE; /* interrupt host */ + mpx_uien = FALSE; /* disable UI */ if (DEBUG_PRI (mpx_dev, DEB_CMDS)) fprintf (sim_deb, ">>MPX cmds: Port %d key %d unsolicited interrupt generated, " @@ -1498,8 +1499,8 @@ switch (mpx_state) { /* dispatch buf_put (iowrite, mpx_port, LF); /* add LF to buffer */ } - buf_term (iowrite, mpx_port, mpx_param >> 8); /* terminate buffer */ - mpx_iolen = -1; /* mark as done */ + buf_term (iowrite, mpx_port, (uint8) (mpx_param >> 8)); /* terminate buffer */ + mpx_iolen = -1; /* mark as done */ } if (DEBUG_PRI (mpx_dev, DEB_CMDS) && @@ -1541,7 +1542,7 @@ switch (mpx_state) { /* dispatch if (i) /* high or low byte? */ mpx_ibuf = mpx_ibuf | ch; /* low byte */ else - mpx_ibuf = ch << 8; /* high byte */ + mpx_ibuf = (uint16) (ch << 8); /* high byte */ mpx_iolen = mpx_iolen - 1; /* drop count */ } @@ -1733,8 +1734,11 @@ while (xmit_loop && (buf_len (iowrite, port, get) > 0)) { /* character availab /* Reception service */ -while (recv_loop && /* OK to process? */ - (chx = tmxr_getc_ln (&mpx_ldsc [port]))) { /* and new char available? */ +while (recv_loop) { /* OK to process? */ + chx = tmxr_getc_ln (&mpx_ldsc [port]); /* get a new character */ + + if (chx == 0) /* if there are no more characters available */ + break; /* then quit the reception loop */ if (chx & SCPE_BREAK) { /* break detected? */ mpx_flags [port] |= FL_BREAK; /* set break status */ @@ -1748,7 +1752,7 @@ while (recv_loop && /* OK to process? */ continue; /* discard NUL that accompanied BREAK */ } - ch = chx & data_mask; /* mask to bits per char */ + ch = (uint8) (chx & data_mask); /* mask to bits per char */ if ((ch == XOFF) && /* XOFF? */ (mpx_flowcntl [port] & FC_XONXOFF)) { /* and handshaking enabled? */ @@ -1822,7 +1826,7 @@ while (recv_loop && /* OK to process? */ } if (uptr->flags & UNIT_CAPSLOCK) /* caps lock mode? */ - ch = toupper (ch); /* convert to upper case if lower */ + ch = (uint8) toupper (ch); /* convert to upper case if lower */ if (rt & RT_ENAB_ECHO) /* echo enabled? */ tmxr_putc_ln (&mpx_ldsc [port], ch); /* echo the char */ @@ -1890,7 +1894,7 @@ while (recv_loop && /* OK to process? */ buf_remove (ioread, port); /* back out dummy char leaving header */ } - buf_term (ioread, port, mpx_param >> 8); /* terminate buffer and set header */ + buf_term (ioread, port, (uint8) (mpx_param >> 8)); /* terminate buffer and set header */ if (buf_avail (ioread, port) == 1) /* first read buffer? */ mpx_flags [port] |= FL_HAVEBUF; /* indicate availability */ @@ -1920,7 +1924,7 @@ if (fast_binary_read) { /* fast binary read } else /* first character */ - mpx_ibuf = (chx & DMASK8) << 8; /* put in top half of word */ + mpx_ibuf = (uint16) ((chx & DMASK8) << 8); /* put in top half of word */ mpx_flags [0] ^= FL_WANTBUF; /* toggle byte flag */ } @@ -2219,7 +2223,7 @@ for (i = 0; i < MPX_PORTS; i++) { /* clear per-line variab if (i == 0) /* default port configurations */ mpx_config [0] = SK_PWRUP_0; /* port 0 is separate from 1-7 */ else - mpx_config [i] = SK_PWRUP_1 | i; + mpx_config [i] = (uint16) (SK_PWRUP_1 | i); mpx_rcvtype [i] = RT_PWRUP; /* power on config for echoplex */ mpx_charcnt [i] = 0; /* default character count */ @@ -2658,9 +2662,9 @@ return; length for the allocated header. */ -static uint32 buf_len (IO_OPER rw, uint32 port, BUF_SELECT which) +static uint16 buf_len (IO_OPER rw, uint32 port, BUF_SELECT which) { -int32 length; +int16 length; if (which == put) length = mpx_put [port] [rw] - mpx_sep [port] [rw] - /* calculate length */ diff --git a/HP2100/hp2100_ms.c b/HP2100/hp2100_ms.c index 603b6fd0..b8c7600a 100644 --- a/HP2100/hp2100_ms.c +++ b/HP2100/hp2100_ms.c @@ -26,6 +26,9 @@ MS 13181A 7970B 800bpi nine track magnetic tape 13183A 7970E 1600bpi nine track magnetic tape + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Use T_ADDR_FMT with t_addr values for 64-bit compatibility + Added casts for explicit downward conversions 11-Dec-14 JDB Updated for new erase gap API, added CRCC/LRCC support 10-Jan-13 MP Added DEV_TAPE to DEVICE flags 09-May-12 JDB Separated assignments from conditional expressions @@ -528,10 +531,10 @@ while (working_set) { case ioIOI: /* I/O data input */ - data = msc_sta & ~STA_DYN; /* get card status */ + data = (uint16) (msc_sta & ~STA_DYN); /* get card status */ if ((uptr->flags & UNIT_OFFLINE) == 0) { /* online? */ - data = data | uptr->UST; /* add unit status */ + data = data | (uint16) uptr->UST; /* add unit status */ if (sim_tape_bot (uptr)) /* BOT? */ data = data | STA_BOT; @@ -551,7 +554,7 @@ while (working_set) { data = data | STA_TBSY | STA_LOCAL; if (ms_ctype == A13183) /* 13183A? */ - data = data | STA_PE | (msc_usl << STA_V_SEL); + data = data | STA_PE | (uint16) (msc_usl << STA_V_SEL); if (DEBUG_PRI (msc_dev, DEB_CPU)) fprintf (sim_deb, ">>MSC LIx: Status = %06o\n", data); @@ -644,7 +647,7 @@ while (working_set) { if (DEBUG_PRI (msc_dev, DEB_CMDS)) fprintf (sim_deb, ">>MSC STC: Unit %d command %03o (%s) scheduled, " - "pos = %d, time = %d\n", + "pos = %" T_ADDR_FMT "d, time = %d\n", msc_usl, uptr->FNC, ms_cmd_name (uptr->FNC), uptr->pos, sched_time); } @@ -741,9 +744,10 @@ switch (uptr->FNC) { /* case on function */ fprintf (sim_deb, ">>MSC svc: Unit %d wrote gap\n", unum); - if ((r = ms_write_gap (uptr)) || /* write tape gap; error? */ - (uptr->FNC != FNC_GFM)) /* not GFM? */ - break; /* bail out now */ + r = ms_write_gap (uptr); /* write tape gap*/ + + if (r || (uptr->FNC != FNC_GFM)) /* if error or not GFM */ + break; /* then bail out now */ /* else drop into WFM */ case FNC_WFM: /* write file mark */ if ((ms_timing == 0) && sim_tape_bot (uptr)) { /* realistic timing + BOT? */ @@ -862,7 +866,7 @@ switch (uptr->FNC) { /* case on function */ } else { /* not 1st, next char */ if (ms_ptr < DBSIZE) { /* room in buffer? */ - msxb[ms_ptr] = msd_buf >> 8; /* store 2 char */ + msxb[ms_ptr] = (uint8) (msd_buf >> 8); /* store 2 char */ msxb[ms_ptr + 1] = msd_buf & 0377; ms_ptr = ms_ptr + 2; } @@ -1303,13 +1307,18 @@ const BOOT_ROM ms_rom = { t_stat msc_boot (int32 unitno, DEVICE *dptr) { -int32 dev; +const int32 dev = msd_dib.select_code; /* get data chan device no */ + +if (unitno != 0) /* boot supported on drive unit 0 only */ + return SCPE_NOFNC; /* report "Command not allowed" if attempted */ + +if (ibl_copy (ms_rom, dev, IBL_OPT, /* copy the boot ROM to memory and configure */ + IBL_MS | IBL_SET_SC (dev))) /* the S register accordingly */ + return SCPE_IERR; /* return an internal error if the copy failed */ + +if ((sim_switches & SWMASK ('S')) && AR) /* if -S is specified and the A register is non-zero */ + SR = SR | 1; /* then set to skip to the file number in A */ -if (unitno != 0) return SCPE_NOFNC; /* only unit 0 */ -dev = msd_dib.select_code; /* get data chan dev */ -if (ibl_copy (ms_rom, dev)) return SCPE_IERR; /* copy boot to memory */ -SR = (SR & IBL_OPT) | IBL_MS | (dev << IBL_V_DEV); /* set SR */ -if ((sim_switches & SWMASK ('S')) && AR) SR = SR | 1; /* skip? */ return SCPE_OK; } diff --git a/HP2100/hp2100_mt.c b/HP2100/hp2100_mt.c index 7fe15a81..ffd25fe7 100644 --- a/HP2100/hp2100_mt.c +++ b/HP2100/hp2100_mt.c @@ -1,6 +1,6 @@ /* hp2100_mt.c: HP 2100 12559A magnetic tape simulator - Copyright (c) 1993-2013, Robert M. Supnik + Copyright (c) 1993-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ MT 12559A 3030 nine track magnetic tape + 24-Dec-14 JDB Added casts for explicit downward conversions 10-Jan-13 MP Added DEV_TAPE to DEVICE flags 09-May-12 JDB Separated assignments from conditional expressions 25-Mar-12 JDB Removed redundant MTAB_VUN from "format" MTAB entry @@ -552,7 +553,7 @@ switch (mtc_fnc) { /* case on function */ if (mtc_1st) mtc_1st = 0; /* no xfr on first */ else { if (mt_ptr < DBSIZE) { /* room in buffer? */ - mtxb[mt_ptr++] = mtc_unit.buf; + mtxb[mt_ptr++] = (uint8) mtc_unit.buf; mtc_sta = mtc_sta & ~STA_BOT; /* clear BOT */ } else mtc_sta = mtc_sta | STA_PAR; diff --git a/HP2100/hp2100_mux.c b/HP2100/hp2100_mux.c index cc64b224..2f5cb950 100644 --- a/HP2100/hp2100_mux.c +++ b/HP2100/hp2100_mux.c @@ -1,6 +1,6 @@ /* hp2100_mux.c: HP 2100 12920A terminal multiplexor simulator - Copyright (c) 2002-2013, Robert M Supnik + Copyright (c) 2002-2014, Robert M Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -25,6 +25,7 @@ MUX,MUXL,MUXM 12920A terminal multiplexor + 24-Dec-14 JDB Added casts for explicit downward conversions 10-Jan-13 MP Added DEV_MUX and additional DEVICE field values 10-Feb-12 JDB Deprecated DEVNO in favor of SC Removed DEV_NET to allow restoration of listening port @@ -711,7 +712,7 @@ while (working_set) { if (muxl_obuf & OTL_TX) { /* transmit? */ if (ln < MUX_LINES) { /* line valid? */ if (muxl_obuf & OTL_P) { /* parameter? */ - mux_xpar[ln] = muxl_obuf; /* store param value */ + mux_xpar[ln] = (uint16) muxl_obuf; /* store param value */ if (DEBUG_PRI (muxu_dev, DEB_CMDS)) fprintf (sim_deb, ">>MUXl cmds: [STC%s] Transmit channel %d parameter %06o stored\n", @@ -723,7 +724,7 @@ while (working_set) { muxl_obuf = /* add parity bit */ muxl_obuf & ~OTL_PAR | XMT_PAR(muxl_obuf); - mux_xbuf[ln] = muxl_obuf; /* load buffer */ + mux_xbuf[ln] = (uint16) muxl_obuf; /* load buffer */ if (sim_is_active (&muxl_unit[ln])) { /* still working? */ mux_sta[ln] = mux_sta[ln] | LIU_LOST; /* char lost */ @@ -748,7 +749,7 @@ while (working_set) { else /* receive */ if (ln < (MUX_LINES + MUX_ILINES)) { /* line valid? */ if (muxl_obuf & OTL_P) { /* parameter? */ - mux_rpar[ln] = muxl_obuf; /* store param value */ + mux_rpar[ln] = (uint16) muxl_obuf; /* store param value */ if (DEBUG_PRI (muxu_dev, DEB_CMDS)) fprintf (sim_deb, ">>MUXl cmds: [STC%s] Receive channel %d parameter %06o stored\n", @@ -889,11 +890,11 @@ while (working_set) { break; - case ioIOI: /* I/O data input */ - data = LIC_MBO | PUT_CCH (muxc_chan) | /* mbo, chan num */ - LIC_TSTI (muxc_chan) | /* I2, I1 */ - (muxc_ota[muxc_chan] & (OTC_ES2 | OTC_ES1)) | /* ES2, ES1 */ - (muxc_lia[muxc_chan] & (LIC_S2 | LIC_S1)); /* S2, S1 */ + case ioIOI: /* I/O data input */ + data = (uint16) (LIC_MBO | PUT_CCH (muxc_chan) | /* mbo, chan num */ + LIC_TSTI (muxc_chan) | /* I2, I1 */ + (muxc_ota[muxc_chan] & (OTC_ES2 | OTC_ES1)) | /* ES2, ES1 */ + (muxc_lia[muxc_chan] & (LIC_S2 | LIC_S1))); /* S2, S1 */ if (DEBUG_PRI (muxu_dev, DEB_CPU)) fprintf (sim_deb, ">>MUXc cpu: [LIx%s] Status = %06o, channel = %d\n", @@ -1148,7 +1149,7 @@ else { /* normal */ tmxr_poll_tx (&mux_desc); /* poll xmt */ } } - mux_rbuf[ln] = c; /* save char */ + mux_rbuf[ln] = (uint16) c; /* save char */ } mux_rchp[ln] = 1; /* char pending */ @@ -1269,7 +1270,7 @@ for (i = MUX_LINES; i < (MUX_LINES + MUX_ILINES); i++) { else { if (mux_rchp[i]) mux_sta[i] = mux_sta[i] | LIU_LOST; mux_rchp[i] = 1; - mux_rbuf[i] = c; + mux_rbuf[i] = (uint16) c; } } return; @@ -1278,7 +1279,7 @@ return; /* Reset an individual line */ -void mux_reset_ln (int32 i) +static void mux_reset_ln (int32 i) { mux_rbuf[i] = mux_xbuf[i] = 0; /* clear state */ mux_rpar[i] = mux_xpar[i] = 0; diff --git a/HP2100/hp2100_stddev.c b/HP2100/hp2100_stddev.c index 217c1a89..7bdaafd5 100644 --- a/HP2100/hp2100_stddev.c +++ b/HP2100/hp2100_stddev.c @@ -1,6 +1,6 @@ /* hp2100_stddev.c: HP2100 standard devices simulator - Copyright (c) 1993-2012, Robert M. Supnik + Copyright (c) 1993-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -28,6 +28,8 @@ TTY 12531C buffered teleprinter interface TBG 12539C time base generator + 30-Dec-14 JDB Added S-register parameters to ibl_copy + 24-Dec-14 JDB Added casts for explicit downward conversions 28-Dec-12 JDB Allocate the TBG logical name during power-on reset 18-Dec-12 MP Now calls sim_activate_time to get remaining poll time 09-May-12 JDB Separated assignments from conditional expressions @@ -610,12 +612,13 @@ const BOOT_ROM ptr_rom = { t_stat ptr_boot (int32 unitno, DEVICE *dptr) { -int32 dev; +const int32 dev = ptr_dib.select_code; /* get device no */ -dev = ptr_dib.select_code; /* get device no */ -if (ibl_copy (ptr_rom, dev)) return SCPE_IERR; /* copy boot to memory */ -SR = (SR & IBL_OPT) | IBL_PTR | (dev << IBL_V_DEV); /* set SR */ -return SCPE_OK; +if (ibl_copy (ptr_rom, dev, IBL_OPT, /* copy the boot ROM to memory and configure */ + IBL_PTR | IBL_SET_SC (dev))) /* the S register accordingly */ + return SCPE_IERR; /* return an internal error if the copy failed */ +else + return SCPE_OK; } @@ -777,7 +780,7 @@ while (working_set) { case ioIOI: /* I/O data input */ - data = tty_buf; + data = (uint16) tty_buf; if (!(tty_mode & TM_KBD) && sim_is_active (&tty_unit[TTO])) data = data | TP_BUSY; diff --git a/HP2100/hp2100_sys.c b/HP2100/hp2100_sys.c index 6515c40d..519b6e57 100644 --- a/HP2100/hp2100_sys.c +++ b/HP2100/hp2100_sys.c @@ -1,6 +1,6 @@ /* hp2100_sys.c: HP 2100 simulator interface - Copyright (c) 1993-2013, Robert M. Supnik + Copyright (c) 1993-2014, Robert M. Supnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -23,6 +23,8 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Robert M Supnik. + 24-Dec-14 JDB Added casts to t_addr and t_value for 64-bit compatibility + Made local routines static 05-Feb-13 JDB Added hp_fprint_stopped to handle HLT instruction message 18-Mar-13 JDB Moved CPU state variable declarations to hp2100_cpu.h 09-May-12 JDB Quieted warnings for assignments in conditional expressions @@ -186,7 +188,7 @@ return TRUE; The checksum includes the origin but not the count. */ -int32 fgetw (FILE *fileref) +static int32 fgetw (FILE *fileref) { int c1, c2; @@ -435,7 +437,7 @@ int32 cflag, cm, i, j, inst, disp; uint32 irq; cflag = (uptr == NULL) || (uptr == &cpu_unit); -inst = val[0]; +inst = (int32) val[0]; if (sw & SWMASK ('A')) { /* ASCII? */ if (inst > 0377) return SCPE_ARG; fprintf (of, FMTASC (inst & 0177)); @@ -460,7 +462,7 @@ if (sw & SIM_SW_STOP) { /* simulator stop? */ if (irq && (!ion_defer || !calc_defer())) { /* pending interrupt and not deferred? */ addr = irq; /* set display address to trap cell */ - inst = val[0] = ReadIO (irq, SMAP); /* load trap cell instruction */ + val[0] = inst = ReadIO (irq, SMAP); /* load trap cell instruction */ val[1] = ReadIO (irq + 1, SMAP); /* might be multi-word */ val[2] = ReadIO (irq + 2, SMAP); /* although it's unlikely */ fprintf (of, "IAK %2o: ", irq); /* report acknowledged interrupt */ @@ -485,8 +487,10 @@ for (i = 0; opc_val[i] >= 0; i++) { /* loop thru ops */ disp = inst & I_DISP; /* displacement */ fprintf (of, "%s ", opcode[i]); /* opcode */ if (inst & I_CP) { /* current page? */ - if (cflag) fprintf (of, "%-o", (addr & I_PAGENO) | disp); - else fprintf (of, "C %-o", disp); + if (cflag) + fprintf (of, "%-o", ((uint32) addr & I_PAGENO) | disp); + else + fprintf (of, "C %-o", disp); } else fprintf (of, "%-o", disp); /* page zero */ if (inst & I_IA) fprintf (of, ",I"); @@ -512,7 +516,7 @@ for (i = 0; opc_val[i] >= 0; i++) { /* loop thru ops */ break; case I_V_EMR: /* extended mem ref */ - fprintf (of, "%s %-o", opcode[i], val[1] & VAMASK); + fprintf (of, "%s %-o", opcode[i], (uint32) val[1] & VAMASK); if (val[1] & I_IA) fprintf (of, ",I"); return -1; /* extra word */ @@ -526,14 +530,14 @@ for (i = 0; opc_val[i] >= 0; i++) { /* loop thru ops */ break; case I_V_EGZ: /* ext grp 1 op + 0 */ - fprintf (of, "%s %-o", opcode[i], val[1] & VAMASK); + fprintf (of, "%s %-o", opcode[i], (uint32) val[1] & VAMASK); if (val[1] & I_IA) fprintf (of, ",I"); return -2; /* extra words */ case I_V_EG2: /* ext grp 2 op */ - fprintf (of, "%s %-o", opcode[i], val[1] & VAMASK); + fprintf (of, "%s %-o", opcode[i], (uint32) val[1] & VAMASK); if (val[1] & I_IA) fprintf (of, ",I"); - fprintf (of, " %-o", val[2] & VAMASK); + fprintf (of, " %-o", (uint32) val[2] & VAMASK); if (val[2] & I_IA) fprintf (of, ",I"); return -2; /* extra words */ @@ -569,14 +573,14 @@ return SCPE_ARG; -1 if error */ -int32 get_addr (char *cptr) +static int32 get_addr (char *cptr) { int32 d; t_stat r; char gbuf[CBUFSIZE]; cptr = get_glyph (cptr, gbuf, ','); /* get next field */ -d = get_uint (gbuf, 8, VAMASK, &r); /* construe as addr */ +d = (int32) get_uint (gbuf, 8, VAMASK, &r); /* construe as addr */ if (r != SCPE_OK) return -1; if (*cptr != 0) { /* more? */ cptr = get_glyph (cptr, gbuf, 0); /* look for indirect */ @@ -640,12 +644,15 @@ if (opcode[i]) { /* found opcode? */ case I_V_MRF: /* mem ref */ cptr = get_glyph (cptr, gbuf, 0); /* get next field */ - if ((k = (strcmp (gbuf, "C") == 0))) { /* C specified? */ + k = strcmp (gbuf, "C"); + if (k == 0) { /* C specified? */ val[0] = val[0] | I_CP; cptr = get_glyph (cptr, gbuf, 0); } - else if ((k = (strcmp (gbuf, "Z") == 0))) { /* Z specified? */ - cptr = get_glyph (cptr, gbuf, ','); + else { + k = strcmp (gbuf, "Z"); + if (k == 0) /* Z specified? */ + cptr = get_glyph (cptr, gbuf, ','); } if ((d = get_addr (gbuf)) < 0) return SCPE_ARG; if ((d & VAMASK) <= I_DISP) val[0] = val[0] | d; @@ -656,7 +663,7 @@ if (opcode[i]) { /* found opcode? */ case I_V_ESH: /* extended shift */ cptr = get_glyph (cptr, gbuf, 0); - d = get_uint (gbuf, 10, 16, &r); + d = (int32) get_uint (gbuf, 10, 16, &r); if ((r != SCPE_OK) || (d == 0)) return SCPE_ARG; val[0] = val[0] | (d & 017); break; @@ -670,7 +677,7 @@ if (opcode[i]) { /* found opcode? */ case I_V_IO1: /* IOT + optional C */ cptr = get_glyph (cptr, gbuf, ','); /* get device */ - d = get_uint (gbuf, 8, I_DEVMASK, &r); + d = (int32) get_uint (gbuf, 8, I_DEVMASK, &r); if (r != SCPE_OK) return SCPE_ARG; val[0] = val[0] | d; if (*cptr != 0) { @@ -682,7 +689,7 @@ if (opcode[i]) { /* found opcode? */ case I_V_IO2: /* IOT */ cptr = get_glyph (cptr, gbuf, 0); /* get device */ - d = get_uint (gbuf, 8, I_DEVMASK, &r); + d = (int32) get_uint (gbuf, 8, I_DEVMASK, &r); if (r != SCPE_OK) return SCPE_ARG; val[0] = val[0] | d; break; @@ -825,7 +832,7 @@ dibptr = (DIB *) dptr->ctxt; if (dibptr == NULL) return SCPE_IERR; -newdev = get_uint (cptr, 8, I_DEVMASK - num, &r); +newdev = (int32) get_uint (cptr, 8, I_DEVMASK - num, &r); if (r != SCPE_OK) return r; diff --git a/HP2100/hp_disclib.c b/HP2100/hp_disclib.c index 5011cfe2..869363b0 100644 --- a/HP2100/hp_disclib.c +++ b/HP2100/hp_disclib.c @@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the authors. + 24-Dec-14 JDB Added casts for explicit downward conversions 27-Oct-14 JDB Corrected the relative movement calculation in start_seek 20-Dec-12 JDB sim_is_active() now returns t_bool 24-Oct-12 JDB Changed CNTLR_OPCODE to title case to avoid name clash @@ -311,8 +312,8 @@ #define GET_HEAD(p) (((p) >> DL_V_HEAD) & DL_M_HEAD) #define GET_SECTOR(p) (((p) >> DL_V_SECTOR) & DL_M_SECTOR) -#define SET_HEAD(c) (((c)->head & DL_M_HEAD) << DL_V_HEAD) -#define SET_SECTOR(c) (((c)->sector & DL_M_SECTOR) << DL_V_SECTOR) +#define SET_HEAD(c) (uint16) (((c)->head & DL_M_HEAD) << DL_V_HEAD) +#define SET_SECTOR(c) (uint16) (((c)->sector & DL_M_SECTOR) << DL_V_SECTOR) /* Drive properties table. @@ -831,8 +832,8 @@ switch (cvptr->opcode) { /* dispatch the command case Request_Status: - cvptr->buffer [0] = /* set the Status-1 value */ - cvptr->spd_unit | SET_S1STAT (cvptr->status); /* into the buffer */ + cvptr->buffer [0] = (uint16) (cvptr->spd_unit /* set the Status-1 value */ + | SET_S1STAT (cvptr->status)); /* into the buffer */ if (cvptr->type == MAC) /* is this a MAC controller? */ if (unit > unit_limit) /* if the unit number is invalid */ @@ -876,8 +877,8 @@ switch (cvptr->opcode) { /* dispatch the command case Request_Syndrome: - cvptr->buffer [0] = /* return the Status-1 value in buffer 0 */ - cvptr->spd_unit | SET_S1STAT (cvptr->status); + cvptr->buffer [0] = (uint16) (cvptr->spd_unit /* return the Status-1 value */ + | SET_S1STAT (cvptr->status)); /* in buffer 0 */ set_address (cvptr, 1); /* return the CHS values in buffer 1-2 */ @@ -2289,8 +2290,12 @@ return SCPE_IOERR; /* return an I/O error t static void set_address (CVPTR cvptr, uint32 index) { -cvptr->buffer [index] = cvptr->cylinder + (cvptr->eoc == SET ? 1 : 0); /* update the cylinder if EOC is set */ -cvptr->buffer [index + 1] = SET_HEAD (cvptr) | SET_SECTOR (cvptr); /* merge the head and sector */ +cvptr->buffer [index] = (uint16) cvptr->cylinder /* update the cylinder if EOC is set */ + + (cvptr->eoc == SET ? 1 : 0); + +cvptr->buffer [index + 1] = SET_HEAD (cvptr) /* merge the head and sector */ + | SET_SECTOR (cvptr); + return; } @@ -2361,8 +2366,8 @@ uint32 model; if (uptr == NULL) /* if the unit is invalid */ return DL_S2ERR | DL_S2NR; /* then it does not respond */ -model = GET_MODEL (uptr->flags); /* get the drive model */ -status = drive_props [model].type | uptr->STAT; /* start with the drive type and unit status */ +model = GET_MODEL (uptr->flags); /* get the drive model */ +status = (uint16) (drive_props [model].type | uptr->STAT); /* start with the drive type and unit status */ if (uptr->flags & UNIT_WPROT) /* is the write protect switch set? */ status |= DL_S2RO; /* set the Protected status bit */