From 76dd31ae027d4216749b070783a6404622def965 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 30 Dec 2014 17:52:13 -0800 Subject: [PATCH] BESM6: Compiler suggested cleanups (MSVC). --- BESM6/besm6_arith.c | 2 +- BESM6/besm6_cpu.c | 8 ++++---- BESM6/besm6_mmu.c | 7 ++++--- BESM6/besm6_sys.c | 16 ++++++++-------- BESM6/besm6_tty.c | 4 +++- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/BESM6/besm6_arith.c b/BESM6/besm6_arith.c index 016c2c01..082078c3 100644 --- a/BESM6/besm6_arith.c +++ b/BESM6/besm6_arith.c @@ -45,7 +45,7 @@ static alureg_t toalu (t_value val) return ret; } -static int inline is_negative (alureg_t *word) +static int SIM_INLINE is_negative (alureg_t *word) { return (word->mantissa & BIT41) != 0; } diff --git a/BESM6/besm6_cpu.c b/BESM6/besm6_cpu.c index 9da7c6be..f1e6fc31 100644 --- a/BESM6/besm6_cpu.c +++ b/BESM6/besm6_cpu.c @@ -54,9 +54,7 @@ #include #include #include -#include #include -#include #include #include @@ -769,11 +767,12 @@ void check_initial_setup () pult[5] = 1 << 21; GRP |= GRP_PANEL_REQ; } else { + struct tm * d; + /* Яч. ГОД обновляем самостоятельно */ time_t t; t_value date; time(&t); - struct tm * d; d = localtime(&t); ++d->tm_mon; date = (t_value) (d->tm_mday / 10) << 33 | @@ -803,9 +802,10 @@ void check_initial_setup () void cpu_one_inst () { int reg, opcode, addr, nextpc, next_mod; + t_value word; corr_stack = 0; - t_value word = mmu_fetch (PC); + word = mmu_fetch (PC); if (RUU & RUU_RIGHT_INSTR) RK = word; /* get right instruction */ else diff --git a/BESM6/besm6_mmu.c b/BESM6/besm6_mmu.c index 7428cb72..486f4e45 100644 --- a/BESM6/besm6_mmu.c +++ b/BESM6/besm6_mmu.c @@ -139,7 +139,7 @@ t_stat mmu_reset (DEVICE *dptr) { int i; for (i = 0; i < 8; ++i) { - BRZ[i] = BAZ[i] = RP[i] = 0; + BRZ[i] = RP[i] = BAZ[i] = 0; } TABST = 0; OLDEST = 0; @@ -209,12 +209,13 @@ void mmu_protection_check (int addr) void mmu_flush (int idx) { + int waddr = BAZ[idx]; + if (! BAZ[idx]) { /* Был пуст после сброса или выталкивания */ return; } /* Вычисляем физический адрес выталкиваемого БРЗ */ - int waddr = BAZ[idx]; waddr = (waddr > 0100000) ? (waddr - 0100000) : (waddr & 01777) | (TLB[waddr >> 10] << 10); memory[waddr] = BRZ[idx]; @@ -626,7 +627,7 @@ void mmu_setprotection (int idx, t_value val) /* Разряды сумматора, записываемые в регистр защиты - 21-28 */ int mask = 0xff << (idx * 8); val = ((val >> 20) & 0xff) << (idx * 8); - RZ = (RZ & ~mask) | val; + RZ = (uint32)((RZ & ~mask) | val); } void mmu_setcache (int idx, t_value val) diff --git a/BESM6/besm6_sys.c b/BESM6/besm6_sys.c index 01014aa2..86cfe8cb 100644 --- a/BESM6/besm6_sys.c +++ b/BESM6/besm6_sys.c @@ -24,7 +24,6 @@ */ #include "besm6_defs.h" #include -#include const char *opname_short_bemsh [64] = { "зп", "зпм", "рег", "счм", "сл", "вч", "вчоб","вчаб", @@ -188,7 +187,7 @@ t_value ieee_to_besm6 (double d) d = frexp (d, &exponent); /* 0.5 <= d < 1.0 */ d = ldexp (d, 40); - word = d; + word = (t_value)d; if (d - word >= 0.5) word += 1; /* Округление. */ if (exponent < -64) @@ -207,6 +206,7 @@ t_value ieee_to_besm6 (double d) double besm6_to_ieee (t_value word) { double mantissa; + int exponent; /* Убираем свертку */ word &= BITS48; @@ -214,9 +214,9 @@ double besm6_to_ieee (t_value word) /* Сдвигаем так, чтобы знак мантиссы пришелся на знак целого; * таким образом, mantissa равно исходной мантиссе, умноженной на 2**63. */ - mantissa = (t_int64) word << (64 - 48 + 7); + mantissa = (double)(((t_int64) word) << (64 - 48 + 7)); - int exponent = word >> 41; + exponent = word >> 41; /* Порядок смещен вверх на 64, и мантиссу нужно скорректировать */ return ldexp (mantissa, exponent - 64 - 63); @@ -472,7 +472,7 @@ t_stat fprint_sym (FILE *of, t_addr addr, t_value *val, if (sw & SWMASK ('M')) { /* symbolic decode? */ if (sw & SIM_SW_STOP && addr == PC && !(RUU & RUU_RIGHT_INSTR)) fprintf (of, "-> "); - besm6_fprint_cmd (of, cmd >> 24); + besm6_fprint_cmd (of, (uint32)(cmd >> 24)); if (sw & SIM_SW_STOP) /* stop point */ fprintf (of, ", "); else @@ -638,7 +638,7 @@ t_stat besm6_load (FILE *input) case 0: /* EOF */ return SCPE_OK; case ':': /* address */ - addr = word; + addr = (int)word; break; case '=': /* word */ if (addr < 010) @@ -655,7 +655,7 @@ t_stat besm6_load (FILE *input) ++addr; break; case '@': /* start address */ - PC = word; + PC = (uint32)word; break; } if (addr > MEMSIZE) @@ -686,7 +686,7 @@ t_stat besm6_dump (FILE *of, char *fnam) last_addr = addr; if (IS_INSN (word)) { fprintf (of, "к "); - besm6_fprint_cmd (of, word >> 24); + besm6_fprint_cmd (of, (uint32)(word >> 24)); fprintf (of, ", "); besm6_fprint_cmd (of, word & BITS(24)); fprintf (of, "\t\t; %05o - ", addr); diff --git a/BESM6/besm6_tty.c b/BESM6/besm6_tty.c index 14ea236e..ad80ec56 100644 --- a/BESM6/besm6_tty.c +++ b/BESM6/besm6_tty.c @@ -166,6 +166,8 @@ t_stat tty_reset (DEVICE *dptr) /* 19 р ГРП, 300 Гц */ t_stat vt_clk (UNIT * this) { + int num; + /* Телетайпы работают на 10 бод */ static int clk_divider = 1<<29; GRP |= MGRP & BBIT(19); @@ -184,7 +186,7 @@ t_stat vt_clk (UNIT * this) } /* Есть новые сетевые подключения? */ - int num = tmxr_poll_conn (&tty_desc); + num = tmxr_poll_conn (&tty_desc); if (num > 0 && num <= LINES_MAX) { char buf [80]; TMLN *t = &tty_line [num];