WARNING: V2.10 has reorganized and renamed some of the definition files for the PDP-10, PDP-11, and VAX. Be sure to delete all previous source files before you unpack the Zip archive, or unpack it into a new directory structure. WARNING: V2.10 has a new, more comprehensive save file format. Restoring save files from previous releases will cause 'invalid register' errors and loss of CPU option flags, device enable/ disable flags, unit online/offline flags, and unit writelock flags. WARNING: If you are using Visual Studio .NET through the IDE, be sure to turn off the /Wp64 flag in the project settings, or dozens of spurious errors will be generated. WARNING: Compiling Ethernet support under Windows requires extra steps; see the Ethernet readme file. Ethernet support is currently available only for Windows, Linux, NetBSD, and OpenBSD. 1. New Features 1.1 SCP and Libraries - The VT emulation package has been replaced by the capability to remote the console to a Telnet session. Telnet clients typically have more complete and robust VT100 emulation. - Simulated devices may now have statically allocated buffers, in addition to dynamically allocated buffers or disk-based data stores. - The DO command now takes substitutable arguments (max 9). In command files, %n represents substitutable argument n. - The initial command line is now interpreted as the command name and substitutable arguments for a DO command. This is backward compatible to prior versions. - The initial command line parses switches. -Q is interpreted as quiet mode; informational messages are suppressed. - The HELP command now takes an optional argument. HELP <cmd> types help on the specified command. - Hooks have been added for implementing GUI-based consoles, as well as simulator-specific command extensions. A few internal data structures and definitions have changed. - Two new routines (tmxr_open_master, tmxr_close_master) have been added to sim_tmxr.c. The calling sequence for sim_accept_conn has been changed in sim_sock.c. - The calling sequence for the VM boot routine has been modified to add an additional parameter. - SAVE now saves, and GET now restores, controller and unit flags. - Library sim_ether.c has been added for Ethernet support. 1.2 VAX - Non-volatile RAM (NVR) can behave either like a memory or like a disk-based peripheral. If unattached, it behaves like memory and is saved and restored by SAVE and RESTORE, respectively. If attached, its contents are loaded from disk by ATTACH and written back to disk at DETACH and EXIT. - SHOW <device> VECTOR displays the device's interrupt vector. A few devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The TK50 (TMSCP tape) has been added. - The DEQNA/DELQA (Qbus Ethernet controllers) have been added. - Autoconfiguration support has been added. - The paper tape reader has been removed from vax_stddev.c and now references a common implementation file, dec_pt.h. - Examine and deposit switches now work on all devices, not just the CPU. - Device address conflicts are not detected until simulation starts. 1.3 PDP-11 - SHOW <device> VECTOR displays the device's interrupt vector. Most devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The TK50 (TMSCP tape), RK611/RK06/RK07 (cartridge disk), RX211 (double density floppy), and KW11P programmable clock have been added. - The DEQNA/DELQA (Qbus Ethernet controllers) have been added. - Autoconfiguration support has been added. - The paper tape reader has been removed from pdp11_stddev.c and now references a common implementation file, dec_pt.h. - Device bootstraps now use the actual CSR specified by the SET ADDRESS command, rather than just the default CSR. Note that PDP-11 operating systems may NOT support booting with non-standard addresses. - Specifying more than 256KB of memory, or changing the bus configuration, causes all peripherals that are not compatible with the current bus configuration to be disabled. - Device address conflicts are not detected until simulation starts. 1.4 PDP-10 - SHOW <device> VECTOR displays the device's interrupt vector. A few devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The RX211 (double density floppy) has been added; it is off by default. - The paper tape now references a common implementation file, dec_pt.h. - Device address conflicts are not detected until simulation starts. 1.5 PDP-1 - DECtape (then known as MicroTape) support has been added. - The line printer and DECtape can be disabled and enabled. 1.6 PDP-8 - The RX28 (double density floppy) has been added as an option to the existing RX8E controller. - SHOW <device> DEVNO displays the device's device number. Most devices allow the device number to be changed with SET <device> DEVNO=nnn. - Device number conflicts are not detected until simulation starts. 1.7 IBM 1620 - The IBM 1620 simulator has been released. 1.8 AltairZ80 - A hard drive has been added for increased storage. - Several bugs have been fixed. 1.9 HP 2100 - The 12845A has been added and made the default line printer (LPT). The 12653A has been renamed LPS and is off by default. It also supports the diagnostic functions needed to run the DCPC and DMS diagnostics. - The 12557A/13210A disk defaults to the 13210A (7900/7901). - The 12559A magtape is off by default. - New CPU options (EAU/NOEAU) enable/disable the extended arithmetic instructions for the 2116. These instructions are standard on the 2100 and 21MX. - New CPU options (MPR/NOMPR) enable/disable memory protect for the 2100 and 21MX. - New CPU options (DMS/NODMS) enable/disable the dynamic mapping instructions for the 21MX. - The 12539 timebase generator autocalibrates. 1.10 Simulated Magtapes - Simulated magtapes recognize end of file and the marker 0xFFFFFFFF as end of medium. Only the TMSCP tape simulator can generate an end of medium marker. - The error handling in simulated magtapes was overhauled to be consistent through all simulators. 1.11 Simulated DECtapes - Added support for RT11 image file format (256 x 16b) to DECtapes. 2. Release Notes 2.1 Bugs Fixed - TS11/TSV05 was not simulating the XS0_MOT bit, causing failures under VMS. In addition, two of the CTL options were coded interchanged. - IBM 1401 tape was not setting a word mark under group mark for load mode reads. This caused the diagnostics to crash. - SCP bugs in ssh_break and set_logon were fixed (found by Dave Hittner). - Numerous bugs in the HP 2100 extended arithmetic, floating point, 21MX, DMS, and IOP instructions were fixed. Bugs were also fixed in the memory protect and DMS functions. The moving head disks (DP, DQ) were revised to simulate the hardware more accurately. Missing functions in DQ (address skip, read address) were added. 2.2 HP 2100 Debugging - The HP 2100 CPU nows runs all of the CPU diagnostics. - The peripherals run most of the peripheral diagnostics. There is still a problem in overlapped seek operation on the disks. See the file hp2100_diag.txt for details. 3. In Progress These simulators are not finished and are available in a separate Zip archive distribution. - Interdata 16b/32b: coded, partially tested. See the file id_diag.txt for details. - SDS 940: coded, partially tested.
388 lines
12 KiB
C
388 lines
12 KiB
C
/* i1620_fp.c: IBM 1620 floating point simulator
|
||
|
||
Copyright (c) 2002, 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"),
|
||
to deal in the Software without restriction, including without limitation
|
||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
and/or sell copies of the Software, and to permit persons to whom the
|
||
Software is furnished to do so, subject to the following conditions:
|
||
|
||
The above copyright notice and this permission notice shall be included in
|
||
all copies or substantial portions of the Software.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
Except as contained in this notice, the name of Robert M Supnik shall not
|
||
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.
|
||
|
||
The IBM 1620 uses a variable length floating point format, with a fixed
|
||
two digit decimal exponent and a variable length decimal mantissa:
|
||
|
||
_ S_S
|
||
M.......MEE
|
||
|
||
where S represents flag bits if the mantissa or exponent are negative.
|
||
*/
|
||
|
||
#include "i1620_defs.h"
|
||
|
||
#define FP_LMAX 100 /* max fp mant lnt */
|
||
#define FP_EMAX 99 /* max fp exponent */
|
||
|
||
/* Unpacked floating point operand */
|
||
|
||
struct fp_opnd {
|
||
int32 sign; /* 0 => +, 1 => - */
|
||
int32 exp; /* binary exponent */
|
||
uint32 lnt; /* mantissa length */
|
||
uint32 addr; /* mantissa addr */
|
||
uint32 zero; /* 0 => nz, 1 => zero */
|
||
};
|
||
|
||
typedef struct fp_opnd FPA;
|
||
|
||
extern uint8 M[MAXMEMSIZE]; /* main memory */
|
||
extern uint8 ind[NUM_IND]; /* indicators */
|
||
extern UNIT cpu_unit;
|
||
|
||
t_stat fp_scan_mant (uint32 ad, uint32 *lnt, uint32 *zro);
|
||
t_stat fp_zero (FPA *fp);
|
||
|
||
extern t_stat xmt_field (uint32 d, uint32 s, uint32 skp);
|
||
extern t_stat add_field (uint32 d, uint32 s, t_bool sub, t_bool sto, int32 *sta);
|
||
extern t_stat mul_field (uint32 d, uint32 s);
|
||
extern t_stat xmt_divd (uint32 d, uint32 s);
|
||
extern t_stat div_field (uint32 dvd, uint32 dvr, int32 *ez);
|
||
|
||
/* Unpack and validate a floating point argument */
|
||
|
||
t_stat fp_unpack (uint32 ad, FPA *fp)
|
||
{
|
||
uint8 d0, d1, esign;
|
||
|
||
esign = M[ad] & FLAG; /* get exp sign */
|
||
d0 = M[ad] & DIGIT; /* get exp lo digit */
|
||
MM (ad);
|
||
if ((M[ad] & FLAG) == 0) return STOP_FPMF; /* no flag on hi exp? */
|
||
d1 = M[ad] & DIGIT; /* get exp hi digit */
|
||
MM (ad);
|
||
fp->addr = ad; /* save mant addr */
|
||
if (BAD_DIGIT (d1) || BAD_DIGIT (d0)) return STOP_INVDIG; /* exp bad dig? */
|
||
fp->exp = ((d1 * 10) + d0) * (esign? -1: 1); /* convert exponent */
|
||
fp->sign = (M[ad] & FLAG)? 1: 0; /* get mantissa sign */
|
||
return fp_scan_mant (fp->addr, &(fp->lnt), &(fp->zero));
|
||
}
|
||
|
||
/* Unpack and validate source and destination arguments */
|
||
|
||
t_stat fp_unpack_two (uint32 dad, uint32 sad, FPA *dfp, FPA *sfp)
|
||
{
|
||
t_stat r;
|
||
|
||
if ((r = fp_unpack (dad, dfp)) != SCPE_OK) return r; /* unpack dst */
|
||
if ((r = fp_unpack (sad, sfp)) != SCPE_OK) return r; /* unpack src */
|
||
if (sfp->lnt != dfp->lnt) return STOP_FPUNL; /* lnts must be equal */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Pack floating point result */
|
||
|
||
t_stat fp_pack (FPA *fp)
|
||
{
|
||
int32 e;
|
||
uint32 i, mad;
|
||
|
||
e = (fp->exp >= 0)? fp->exp: -fp->exp; /* get |exp| */
|
||
if (e > FP_EMAX) { /* too big? */
|
||
ind[IN_EXPCHK] = 1; /* set indicator */
|
||
if (fp->exp < 0) return fp_zero (fp); /* underflow? */
|
||
mad = fp->addr;
|
||
for (i = 0; i < fp->lnt; i++) { /* mant = 99...99 */
|
||
M[mad] = (M[mad] & FLAG) | 9;
|
||
MM (mad); }
|
||
e = FP_EMAX; } /* cap at max */
|
||
M[ADDR_A (fp->addr, 1)] = (e / 10) | FLAG; /* high exp digit */
|
||
M[ADDR_A (fp->addr, 2)] = (e % 10) | /* low exp digit */
|
||
((fp->exp < 0)? FLAG: 0);
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Shift mantissa right n positions */
|
||
|
||
void fp_rsh (FPA *fp, uint32 n)
|
||
{
|
||
uint32 i, sad, dad;
|
||
|
||
if (n == 0) return; /* zero? done */
|
||
sad = ADDR_S (fp->addr, n); /* src = addr - n */
|
||
dad = fp->addr; /* dst = n */
|
||
for (i = 0; i < fp->lnt; i++) { /* move digits */
|
||
if (i >= (fp->lnt - n)) M[dad] = M[dad] & FLAG;
|
||
else M[dad] = (M[dad] & FLAG) | (M[sad] & DIGIT);
|
||
MM (dad);
|
||
MM (sad); }
|
||
return;
|
||
}
|
||
|
||
/* Shift mantissa left 1 position */
|
||
|
||
void fp_lsh_1 (FPA *fp)
|
||
{
|
||
uint32 i, mad, nxt;
|
||
|
||
mad = ADDR_S (fp->addr, fp->lnt - 1); /* hi order digit */
|
||
for (i = 0; i < (fp->lnt - 1); i++) { /* move lnt-1 digits */
|
||
nxt = ADDR_A (mad, 1);
|
||
M[mad] = (M[mad] & FLAG) | (M[nxt] & DIGIT);
|
||
mad = nxt; }
|
||
M[mad] = M[mad] & FLAG; /* clear last digit */
|
||
return;
|
||
}
|
||
|
||
/* Clear floating point number */
|
||
|
||
t_stat fp_zero (FPA *fp)
|
||
{
|
||
uint32 i, mad = fp->addr;
|
||
|
||
for (i = 0; i < fp->lnt; i++) { /* clear mantissa */
|
||
M[mad] = (i? M[mad] & FLAG: 0); /* clear sign bit */
|
||
MM (mad); }
|
||
M[ADDR_A (fp->addr, 1)] = FLAG + 9; /* exp = -99 */
|
||
M[ADDR_A (fp->addr, 2)] = FLAG + 9; /* exp = -99 */
|
||
ind[IN_EZ] = 1; /* result = 0 */
|
||
ind[IN_HP] = 0;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Scan floating point mantissa for length and (optionally) zero */
|
||
|
||
t_stat fp_scan_mant (uint32 ad, uint32 *lnt, uint32 *zro)
|
||
{
|
||
uint8 d, l, z;
|
||
|
||
z = 1; /* assume zero */
|
||
for (l = 1; l <= FP_LMAX; l++) { /* scan to get length */
|
||
d = M[ad] & DIGIT; /* get mant digit */
|
||
if (d) z = 0; /* non-zero? */
|
||
if ((l != 1) && (M[ad] & FLAG)) { /* flag past first dig? */
|
||
*lnt = l; /* set returns */
|
||
if (zro) *zro = z;
|
||
return SCPE_OK; }
|
||
MM (ad); }
|
||
return STOP_FPLNT; /* too long */
|
||
}
|
||
|
||
/* Copy floating point mantissa */
|
||
|
||
void fp_copy_mant (uint32 d, uint32 s, uint32 l)
|
||
{
|
||
uint32 i;
|
||
|
||
if (ind[IN_HP]) M[d] = M[d] & ~FLAG; /* clr/set sign */
|
||
else M[d] = M[d] | FLAG;
|
||
for (i = 0; i < l; i++) { /* copy src */
|
||
M[d] = (M[d] & FLAG) | (M[s] & DIGIT); /* preserve flags */
|
||
MM (d);
|
||
MM (s); }
|
||
return;
|
||
}
|
||
|
||
/* Compare floating point mantissa */
|
||
|
||
int32 fp_comp_mant (uint32 d, uint32 s, uint32 l)
|
||
{
|
||
uint8 i, dd, sd;
|
||
|
||
d = ADDR_S (d, l - 1); /* start of mantissa */
|
||
s = ADDR_S (s, l - 1);
|
||
for (i = 0; i < l; i++) { /* compare dst:src */
|
||
dd = M[d] & DIGIT; /* get dst digit */
|
||
sd = M[s] & DIGIT; /* get src digit */
|
||
if (dd > sd) return 1; /* >? done */
|
||
if (dd < sd) return -1; /* <? done */
|
||
PP (d); /* =? continue */
|
||
PP (s); }
|
||
return 0; /* done, equal */
|
||
}
|
||
|
||
/* Floating point add */
|
||
|
||
t_stat fp_add (uint32 d, uint32 s, t_bool sub)
|
||
{
|
||
FPA sfp, dfp;
|
||
uint32 i, sad, hi;
|
||
int32 dif, sta;
|
||
uint8 sav_src[FP_LMAX];
|
||
t_stat r;
|
||
|
||
r = fp_unpack_two (d, s, &dfp, &sfp); /* unpack operands */
|
||
if (r != SCPE_OK) return r; /* error? */
|
||
dif = dfp.exp - sfp.exp; /* exp difference */
|
||
|
||
if (sfp.zero || (dif >= ((int32) dfp.lnt))) { /* src = 0, or too small? */
|
||
if (dfp.zero) return fp_zero (&dfp); /* res = dst, zero? */
|
||
ind[IN_EZ] = 0; /* res nz, set EZ, HP */
|
||
ind[IN_HP] = (dfp.sign == 0);
|
||
return SCPE_OK; }
|
||
if (dfp.zero || (dif <= -((int32) dfp.lnt))) { /* dst = 0, or too small? */
|
||
if (sfp.zero) return fp_zero (&dfp); /* res = src, zero? */
|
||
r = xmt_field (d, s, 3); /* copy src to dst */
|
||
ind[IN_EZ] = 0; /* res nz, set EZ, HP */
|
||
ind[IN_HP] = (dfp.sign == 0);
|
||
return r; }
|
||
|
||
if (dif > 0) { /* dst exp > src exp? */
|
||
sad = sfp.addr; /* save src in save area */
|
||
for (i = 0; i < sfp.lnt; i++) {
|
||
sav_src[i] = M[sad];
|
||
MM (sad); }
|
||
fp_rsh (&sfp, dif); } /* denormalize src */
|
||
else if (dif < 0) { /* dst exp < src exp? */
|
||
dfp.exp = sfp.exp; /* res exp = src exp */
|
||
fp_rsh (&dfp, -dif); } /* denormalize dst */
|
||
r = add_field (dfp.addr, sfp.addr, sub, TRUE, &sta); /* add mant, set EZ, HP */
|
||
if (dif > 0) { /* src denormalized? */
|
||
sad = sfp.addr; /* restore src from */
|
||
for (i = 0; i < sfp.lnt; i++) { /* save area */
|
||
M[sad] = sav_src[i];
|
||
MM (sad); } }
|
||
if (r != SCPE_OK) return r; /* add error? */
|
||
|
||
hi = ADDR_S (dfp.addr, dfp.lnt - 1); /* addr of hi digit */
|
||
if (sta == ADD_CARRY) { /* carry out? */
|
||
fp_rsh (&dfp, 1); /* shift mantissa */
|
||
M[hi] = FLAG + 1; /* high order 1 */
|
||
dfp.exp = dfp.exp + 1;
|
||
ind[IN_EZ] = 0; /* not zero */
|
||
ind[IN_HP] = (dfp.sign == 0); } /* set HP */
|
||
else if (ind[IN_EZ]) return fp_zero (&dfp); /* result zero? */
|
||
else { while ((M[hi] & DIGIT) == 0) { /* until normalized */
|
||
fp_lsh_1 (&dfp); /* left shift */
|
||
dfp.exp = dfp.exp - 1; } } /* decr exponent */
|
||
|
||
return fp_pack (&dfp); /* pack and exit */
|
||
}
|
||
|
||
/* Floating point multiply */
|
||
|
||
t_stat fp_mul (uint32 d, uint32 s)
|
||
{
|
||
FPA sfp, dfp;
|
||
uint32 pad;
|
||
t_stat r;
|
||
|
||
r = fp_unpack_two (d, s, &dfp, &sfp); /* unpack operands */
|
||
if (r != SCPE_OK) return r; /* error? */
|
||
if (sfp.zero || dfp.zero) return fp_zero (&dfp); /* either zero? */
|
||
|
||
r = mul_field (dfp.addr, sfp.addr); /* mul, set EZ, HP */
|
||
if (r != SCPE_OK) return r;
|
||
if (M[ADDR_S (PROD_AREA_END, 2 * dfp.lnt)] & DIGIT) { /* hi prod dig set? */
|
||
pad = ADDR_S (PROD_AREA_END - 1, dfp.lnt); /* no normalization */
|
||
dfp.exp = dfp.exp + sfp.exp; } /* res exp = sum */
|
||
else { pad = ADDR_S (PROD_AREA_END, dfp.lnt); /* 'normalize' 1 */
|
||
dfp.exp = dfp.exp + sfp.exp - 1; } /* res exp = sum - 1 */
|
||
fp_copy_mant (dfp.addr, pad, dfp.lnt); /* copy prod to mant */
|
||
|
||
return fp_pack (&dfp); /* pack and exit */
|
||
}
|
||
|
||
/* Floating point divide */
|
||
|
||
t_stat fp_div (uint32 d, uint32 s)
|
||
{
|
||
FPA sfp, dfp;
|
||
uint32 i, pad, a100ml, a99ml;
|
||
int32 ez;
|
||
t_stat r;
|
||
|
||
r = fp_unpack_two (d, s, &dfp, &sfp); /* unpack operands */
|
||
if (r != SCPE_OK) return r; /* error? */
|
||
if (sfp.zero) { /* divide by zero? */
|
||
ind[IN_OVF] = 1; /* dead jim */
|
||
return SCPE_OK; }
|
||
if (dfp.zero) return fp_zero (&dfp); /* divide into zero? */
|
||
|
||
for (i = 0; i < PROD_AREA_LEN; i++) /* clear prod area */
|
||
M[PROD_AREA + i] = 0;
|
||
a100ml = ADDR_S (PROD_AREA_END, dfp.lnt); /* 100 - lnt */
|
||
a99ml = ADDR_S (PROD_AREA_END - 1, dfp.lnt); /* 99 - lnt */
|
||
if (fp_comp_mant (dfp.addr, sfp.addr, dfp.lnt) >= 0) { /* |Mdst| >= |Msrc|? */
|
||
pad = a100ml;
|
||
dfp.exp = dfp.exp - sfp.exp + 1; } /* res exp = diff + 1 */
|
||
else { pad = a99ml;
|
||
dfp.exp = dfp.exp - sfp.exp; } /* res exp = diff */
|
||
r = xmt_divd (pad, dfp.addr); /* xmt dividend */
|
||
if (r != SCPE_OK) return r; /* error? */
|
||
r = div_field (a100ml, sfp.addr, &ez); /* divide fractions */
|
||
if (r != SCPE_OK) return r; /* error? */
|
||
if (ez) return fp_zero (&dfp); /* result zero? */
|
||
|
||
ind[IN_HP] = ((dfp.sign ^ sfp.sign) == 0); /* set res sign */
|
||
ind[IN_EZ] = 0; /* not zero */
|
||
fp_copy_mant (dfp.addr, a99ml, dfp.lnt); /* copy result */
|
||
|
||
return fp_pack (&dfp);
|
||
}
|
||
|
||
/* Floating shift right */
|
||
|
||
t_stat fp_fsr (uint32 d, uint32 s)
|
||
{
|
||
uint32 cnt;
|
||
uint8 t;
|
||
|
||
if (d == s) return SCPE_OK; /* no move? */
|
||
|
||
cnt = 0;
|
||
M[d] = (M[d] & FLAG) | (M[s] & DIGIT); /* move 1st wo flag */
|
||
do { MM (d); /* decr ptrs */
|
||
MM (s);
|
||
t = M[d] = M[s] & (FLAG | DIGIT); /* copy others */
|
||
if (cnt++ > MEMSIZE) return STOP_FWRAP; } /* (stop runaway) */
|
||
while ((t & FLAG) == 0); /* until src flag */
|
||
|
||
cnt = 0;
|
||
do { MM (d); /* decr pointer */
|
||
t = M[d]; /* save old val */
|
||
M[d] = 0; /* zero field */
|
||
if (cnt++ > MEMSIZE) return STOP_FWRAP; } /* (stop runaway) */
|
||
while ((t & FLAG) == 0); /* until dst flag */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Floating shift left - note that dst is addr of high order digit */
|
||
|
||
t_stat fp_fsl (uint32 d, uint32 s)
|
||
{
|
||
uint32 i, lnt;
|
||
uint8 sign;
|
||
t_stat r;
|
||
|
||
if (d == s) return SCPE_OK;
|
||
sign = M[s] & FLAG; /* get src sign */
|
||
r = fp_scan_mant (s, &lnt, NULL); /* get src length */
|
||
if (r != SCPE_OK) return r; /* error? */
|
||
s = ADDR_S (s, lnt - 1); /* hi order src */
|
||
M[d] = M[s] & (FLAG | DIGIT); /* move 1st w flag */
|
||
M[s] = M[s] & ~FLAG; /* clr flag from src */
|
||
for (i = 1; i < lnt; i++) { /* move src to dst */
|
||
PP (d); /* incr ptrs */
|
||
PP (s);
|
||
M[d] = M[s] & DIGIT; } /* move just digit */
|
||
PP (d); /* incr pointer */
|
||
while ((M[d] & FLAG) == 0) { /* until flag */
|
||
M[d] = 0; /* clear field */
|
||
PP (d); }
|
||
if (sign) M[d] = FLAG; /* -? zero under sign */
|
||
return SCPE_OK;
|
||
}
|