Merge branch 'master' of https://github.com/leobru/simh
This commit is contained in:
commit
9568d1c1df
16 changed files with 70 additions and 42 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -54,9 +54,7 @@
|
|||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
*/
|
||||
#include "besm6_defs.h"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
t_stat fs_event (UNIT *u);
|
||||
t_stat uvvk_event (UNIT *u);
|
||||
|
@ -125,13 +124,7 @@ t_stat fs_attach (UNIT *u, char *cptr)
|
|||
s = attach_unit (u, cptr);
|
||||
if (s != SCPE_OK)
|
||||
return s;
|
||||
struct stat stbuf;
|
||||
fstat (fileno(u->fileref), &stbuf);
|
||||
isfifo[num] = (stbuf.st_mode & S_IFIFO) != 0;
|
||||
if (isfifo[num]) {
|
||||
int flags = fcntl(fileno(u->fileref), F_GETFL, 0);
|
||||
fcntl(fileno(u->fileref), F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
isfifo[num] = (0 == sim_set_fifo_nonblock (u->fileref));
|
||||
ENB_RDY(FS1_READY >> num);
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
*/
|
||||
#include "besm6_defs.h"
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -393,7 +393,7 @@ while (reason == 0) {
|
|||
}
|
||||
|
||||
if (sim_interval <= 0) { /* chk clock queue */
|
||||
if (reason = sim_process_event ()) break;
|
||||
if ((reason = sim_process_event ())) break;
|
||||
intr_summ = pal_eval_intr (1); /* eval interrupts */
|
||||
}
|
||||
|
||||
|
@ -1433,7 +1433,7 @@ while (reason == 0) {
|
|||
|
||||
case 0x39: /* MINSW4 */
|
||||
if (!(arch_mask & AMASK_MVI)) ABORT (EXC_RSVI);
|
||||
for (i = 0, res = 0; i < 8; i = i++) {
|
||||
for (i = 0, res = 0; i < 8; i++) {
|
||||
s1 = SEXT_W_Q (R[ra] >> (i << 4));
|
||||
s2 = SEXT_W_Q (rbv >> (i << 4));
|
||||
res = res | (((s1 <= s2)? R[ra]: rbv) & word_mask[i]);
|
||||
|
@ -1451,7 +1451,7 @@ while (reason == 0) {
|
|||
|
||||
case 0x3B: /* MINUW4 */
|
||||
if (!(arch_mask & AMASK_MVI)) ABORT (EXC_RSVI);
|
||||
for (i = 0, res = 0; i < 8; i = i++) {
|
||||
for (i = 0, res = 0; i < 8; i++) {
|
||||
s64 = R[ra] & word_mask[i];
|
||||
t64 = rbv & word_mask[i];
|
||||
res = res | ((s64 <= t64)? s64: t64);
|
||||
|
@ -1469,7 +1469,7 @@ while (reason == 0) {
|
|||
|
||||
case 0x3D: /* MAXUW4 */
|
||||
if (!(arch_mask & AMASK_MVI)) ABORT (EXC_RSVI);
|
||||
for (i = 0, res = 0; i < 8; i = i++) {
|
||||
for (i = 0, res = 0; i < 8; i++) {
|
||||
s64 = R[ra] & word_mask[i];
|
||||
t64 = rbv & word_mask[i];
|
||||
res = res | ((s64 >= t64)? s64: t64);
|
||||
|
@ -1487,7 +1487,7 @@ while (reason == 0) {
|
|||
|
||||
case 0x3F: /* MAXSW4 */
|
||||
if (!(arch_mask & AMASK_MVI)) ABORT (EXC_RSVI);
|
||||
for (i = 0, res = 0; i < 8; i = i++) {
|
||||
for (i = 0, res = 0; i < 8; i++) {
|
||||
s1 = SEXT_W_Q (R[ra] >> (i << 4));
|
||||
s2 = SEXT_W_Q (rbv >> (i << 4));
|
||||
res = res | (((s1 >= s2)? R[ra]: rbv) & word_mask[i]);
|
||||
|
@ -1834,7 +1834,7 @@ return SCPE_OK;
|
|||
|
||||
t_stat cpu_show_hist (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||||
{
|
||||
uint32 k, di, lnt;
|
||||
int32 k, di, lnt;
|
||||
char *cptr = (char *) desc;
|
||||
t_stat r;
|
||||
InstHistory *h;
|
||||
|
|
|
@ -34,11 +34,7 @@
|
|||
#include "sim_defs.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
#if defined (__GNUC__)
|
||||
#define INLINE inline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
/* Configuration */
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ if ((dtlb_spage & SPEN_43) && (VPN_GETSP43 (vpn) == 2))
|
|||
return (va & SP43_MASK); /* 43b superpage? */
|
||||
if ((dtlb_spage & SPEN_32) && (VPN_GETSP32 (vpn) == 0x1FFE))
|
||||
return (va & SP32_MASK); /* 32b superpage? */
|
||||
if (tlbp = dtlb_lookup (vpn)) /* try TLB */
|
||||
if ((tlbp = dtlb_lookup (vpn))) /* try TLB */
|
||||
return PHYS_ADDR (tlbp->pfn, va); /* found it */
|
||||
if (ev5_mcsr & MCSR_NT) exc = cons_find_pte_nt (va, &pte64);
|
||||
else exc = cons_find_pte_srm (va, &pte64);
|
||||
|
|
|
@ -904,7 +904,8 @@ t_stat parse_pal_hwre (char *cptr, t_value *inst)
|
|||
{
|
||||
uint32 i, d, val = 0;
|
||||
int32 reg;
|
||||
char *tptr, gbuf[CBUFSIZE];
|
||||
const char *tptr;
|
||||
char gbuf[CBUFSIZE];
|
||||
t_stat r;
|
||||
|
||||
cptr = get_glyph (cptr, gbuf, '/');
|
||||
|
|
|
@ -209,7 +209,7 @@ t_uint64 vax_cvtif (t_uint64 val, uint32 ir, uint32 dp)
|
|||
UFP a;
|
||||
|
||||
if (val == 0) return 0; /* 0? return +0 */
|
||||
if (val < 0) { /* < 0? */
|
||||
if ((val & Q_SIGN) != 0) { /* < 0? */
|
||||
a.sign = 1; /* set sign */
|
||||
val = NEG_Q (val); /* |val| */
|
||||
}
|
||||
|
|
|
@ -716,7 +716,8 @@ t_uint64 bra, df, db;
|
|||
uint32 i, k, lit8, fl;
|
||||
int32 reg;
|
||||
t_stat r;
|
||||
char *tptr, gbuf[CBUFSIZE];
|
||||
const char *tptr;
|
||||
char gbuf[CBUFSIZE];
|
||||
|
||||
if ((r = parse_pal_hwre (cptr, inst)) < 0) return r; /* PAL hardware? */
|
||||
cptr = get_glyph (cptr, gbuf, 0); /* get opcode */
|
||||
|
|
6
makefile
6
makefile
|
@ -1175,10 +1175,12 @@ FORMATDISK = ${BESM6D}/formatdisk.c
|
|||
|
||||
ifeq (,${VIDEO_LDFLAGS})
|
||||
BESM6_OPT = -I ${BESM6D} -DUSE_INT64
|
||||
else ifneq (,$(and $(findstring,SDL2,${VIDEO_LDFLAGS})),$(and($(find_include, SDL2/SDL_ttf),$(find_lib,SDL2_ttf))))
|
||||
else ifneq (,$(and $(findstring SDL2,${VIDEO_LDFLAGS}),$(call find_include,SDL2/SDL_ttf),$(call find_lib,SDL2_ttf)))
|
||||
BESM6_OPT = -I ${BESM6D} -DUSE_INT64 ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL2_ttf
|
||||
else ifneq (,$(and $(find_include, SDL/SDL_ttf),$(find_lib,SDL_ttf)))
|
||||
else ifneq (,$(and $(call find_include,SDL/SDL_ttf),$(call find_lib,SDL_ttf)))
|
||||
BESM6_OPT = -I ${BESM6D} -DUSE_INT64 ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL_ttf
|
||||
else
|
||||
BESM6_OPT = -I ${BESM6D} -DUSE_INT64
|
||||
endif
|
||||
|
||||
###
|
||||
|
|
|
@ -246,7 +246,13 @@ typedef uint32 t_addr;
|
|||
|
||||
/* Stubs for inlining */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define SIM_INLINE _inline
|
||||
#elif defined(__GNUC__)
|
||||
#define SIM_INLINE inline
|
||||
#else
|
||||
#define SIM_INLINE
|
||||
#endif
|
||||
|
||||
/* System independent definitions */
|
||||
|
||||
|
|
25
sim_fio.c
25
sim_fio.c
|
@ -369,10 +369,35 @@ int sim_set_fsize (FILE *fptr, t_addr size)
|
|||
{
|
||||
return _chsize(_fileno(fptr), (long)size);
|
||||
}
|
||||
|
||||
int sim_set_fifo_nonblock (FILE *fptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* !defined(_WIN32) */
|
||||
#include <unistd.h>
|
||||
int sim_set_fsize (FILE *fptr, t_addr size)
|
||||
{
|
||||
return ftruncate(fileno(fptr), (off_t)size);
|
||||
}
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int sim_set_fifo_nonblock (FILE *fptr)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if (!fptr || fstat (fileno(fptr), &stbuf))
|
||||
return -1;
|
||||
#if defined(S_IFIFO) && defined(O_NONBLOCK)
|
||||
if ((stbuf.st_mode & S_IFIFO)) {
|
||||
int flags = fcntl(fileno(fptr), F_GETFL, 0);
|
||||
return fcntl(fileno(fptr), F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,7 @@ FILE *sim_fopen (const char *file, const char *mode);
|
|||
int sim_fseek (FILE *st, t_addr offset, int whence);
|
||||
int sim_fseeko (FILE *st, t_offset offset, int whence);
|
||||
int sim_set_fsize (FILE *fptr, t_addr size);
|
||||
int sim_set_fifo_nonblock (FILE *fptr);
|
||||
size_t sim_fread (void *bptr, size_t size, size_t count, FILE *fptr);
|
||||
size_t sim_fwrite (void *bptr, size_t size, size_t count, FILE *fptr);
|
||||
uint32 sim_fsize (FILE *fptr);
|
||||
|
|
Loading…
Add table
Reference in a new issue