+13-Nov-89 Ceriel Jacobs (ceriel) at ceriel
+ Many changes for speed-up (resulting speed-up: 20-25%).
+ Also fixed serious problem in floating point handling: the existing
+ code assumed that the low order 4 bytes of a double could be used as
+ a float (4 bytes). This is NOT true for most floating point
+ implementations, notably IEEE ones.
+
3-Oct-88 Dick Grune (dick) at dick
Since the definitions of VERSION and MAGIC are now available from
standard include files, e.out.h can be simplified.
if (in_stack(p)) {
wtrap(WHPSTACK, EHEAP);
}
- if (!is_aligned(p, wsize)) {
+ if (!is_wordaligned(p)) {
wtrap(WHPODD, EHEAP);
}
if (maxheap) {
************************************************************************/
dt_stdp(addr, ap)
- ptr addr, ap;
+ register ptr addr;
+ ptr ap;
{
register int i;
register long p = (long) ap;
LOG(("@g6 dt_stdp(%lu, %lu)", addr, p));
ch_in_data(addr, psize);
- ch_aligned(addr, wsize);
- for (i = 0; i < (int) psize; i++) {
- ch_dt_prot(addr + i);
- data_loc(addr + i) = (char) (p);
- dt_dp(addr + i);
+ ch_wordaligned(addr);
+ for (i = (int) psize; i > 0; i--, addr++) {
+ ch_dt_prot(addr);
+ data_loc(addr) = (char) (p);
+ dt_dp(addr);
p = p>>8;
}
}
dt_stip(addr, ap)
- ptr addr, ap;
+ register ptr addr;
+ ptr ap;
{
register int i;
register long p = (long) ap;
LOG(("@g6 dt_stip(%lu, %lu)", addr, p));
ch_in_data(addr, psize);
- ch_aligned(addr, wsize);
- for (i = 0; i < (int) psize; i++) {
- ch_dt_prot(addr + i);
- data_loc(addr + i) = (char) (p);
- dt_ip(addr + i);
+ ch_wordaligned(addr);
+ for (i = (int) psize; i > 0; i--, addr++) {
+ ch_dt_prot(addr);
+ data_loc(addr) = (char) (p);
+ dt_ip(addr);
p = p>>8;
}
}
dt_stn(addr, al, n)
- ptr addr;
+ register ptr addr;
long al;
size n;
{
register int i;
register long l = al;
+#ifdef LOGGING
+ /* a psize zero is ambiguous */
+ int sh_flags = (l == 0 && n == psize) ? (SH_INT|SH_DATAP) : SH_INT;
+#endif LOGGING
LOG(("@g6 dt_stn(%lu, %lu, %lu)", addr, l, n));
ch_in_data(addr, n);
ch_aligned(addr, n);
- for (i = 0; i < (int) n; i++) {
- ch_dt_prot(addr + i);
- data_loc(addr + i) = (char) l;
-#ifdef LOGGING
- if (al == 0 && n == psize) {
- /* a psize zero, ambiguous */
- dt_sh(addr + i) = (SH_INT|SH_DATAP);
- }
- else {
- dt_sh(addr + i) = SH_INT;
- }
+ for (i = (int) n; i > 0; i--, addr++) {
+ ch_dt_prot(addr);
+ data_loc(addr) = (char) l;
+#ifdef LOGGING
+ dt_sh(addr) = sh_flags;
#endif LOGGING
l = l>>8;
}
#ifndef NOFLOAT
dt_stf(addr, f, n)
- ptr addr;
+ register ptr addr;
double f;
- size n;
+ register size n;
{
register char *cp = (char *) &f;
register int i;
+ float fl;
LOG(("@g6 dt_stf(%lu, %g, %lu)", addr, f, n));
ch_in_data(addr, n);
- ch_aligned(addr, wsize);
- for (i = 0; i < (int) n; i++) {
- ch_dt_prot(addr + i);
- data_loc(addr + i) = *cp++;
- dt_fl(addr + i);
+ ch_wordaligned(addr);
+ if ((int) n == 4) {
+ fl = f;
+ cp = (char *) &fl;
+ }
+ for (i = (int) n; i > 0; i--, addr++) {
+ ch_dt_prot(addr);
+ data_loc(addr) = *cp++;
+ dt_fl(addr);
}
}
#endif NOFLOAT
************************************************************************/
ptr dt_lddp(addr)
- ptr addr;
+ register ptr addr;
{
register ptr p;
LOG(("@g6 dt_lddp(%lu)", addr));
ch_in_data(addr, psize);
- ch_aligned(addr, wsize);
+ ch_wordaligned(addr);
#ifdef LOGGING
if (!is_dt_set(addr, psize, SH_DATAP)) {
warning(WGDPEXP);
}
ptr dt_ldip(addr)
- ptr addr;
+ register ptr addr;
{
register ptr p;
LOG(("@g6 dt_ldip(%lu)", addr));
ch_in_data(addr, psize);
- ch_aligned(addr, wsize);
+ ch_wordaligned(addr);
#ifdef LOGGING
if (!is_dt_set(addr, psize, SH_INSP)) {
warning(WGIPEXP);
}
unsigned long dt_ldu(addr, n)
- ptr addr;
+ register ptr addr;
size n;
{
register int i;
}
long dt_lds(addr, n)
- ptr addr;
+ register ptr addr;
size n;
{
register int i;
************************************************************************/
dt_mvd(d2, d1, n) /* d1 -> d2 */
- ptr d2, d1;
+ register ptr d2, d1;
size n;
{
register int i;
ch_in_data(d1, n);
- ch_aligned(d1, wsize);
+ ch_wordaligned(d1);
ch_in_data(d2, n);
- ch_aligned(d2, wsize);
+ ch_wordaligned(d2);
- for (i = 0; i < (int) n; i++) {
- ch_dt_prot(d2 + i);
- data_loc(d2 + i) = data_loc(d1 + i);
+ for (i = (int) n; i > 0; i--, d1++, d2++) {
+ ch_dt_prot(d2);
+ data_loc(d2) = data_loc(d1);
#ifdef LOGGING
- dt_sh(d2 + i) = dt_sh(d1 + i) & ~SH_PROT;
+ dt_sh(d2) = dt_sh(d1) & ~SH_PROT;
#endif LOGGING
}
}
dt_mvs(d, s, n) /* s -> d */
- ptr d, s;
+ register ptr d, s;
size n;
{
register int i;
ch_in_stack(s, n);
- ch_aligned(s, wsize);
+ ch_wordaligned(s);
ch_in_data(d, n);
- ch_aligned(d, wsize);
+ ch_wordaligned(d);
- for (i = 0; i < (int) n; i++) {
- ch_dt_prot(d + i);
- ch_st_prot(s + i);
- data_loc(d + i) = stack_loc(s + i);
+ for (i = (int) n; i > 0; i--, d++, s++) {
+ ch_dt_prot(d);
+ ch_st_prot(s);
+ data_loc(d) = stack_loc(s);
#ifdef LOGGING
- dt_sh(d + i) = st_sh(s + i) & ~SH_PROT;
+ dt_sh(d) = st_sh(s) & ~SH_PROT;
#endif LOGGING
}
}
#ifdef LOGGING
PRIVATE warn_dtbits(addr, n)
- ptr addr;
- size n;
+ register ptr addr;
+ register size n;
{
register int or_bits = 0;
register int and_bits = 0xff;
LOG(("@T6 DoCMIl2(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
}
DoCMIm(arg)
LOG(("@T6 DoCMIm(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
}
DoCMIz()
LOG(("@T6 DoCMIz(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
}
DoCMFl2(arg)
LOG(("@T6 DoCMFl2(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
#else NOFLOAT
arg = arg;
nofloat();
LOG(("@T6 DoCMFs(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
#else NOFLOAT
hob = hob;
wfac = wfac;
LOG(("@T6 DoCMFz(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
#else NOFLOAT
nofloat();
#endif NOFLOAT
LOG(("@T6 DoCMUl2(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
}
DoCMUz()
LOG(("@T6 DoCMUz(%ld)", l));
spoilFRA();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
}
DoCMSl2(arg)
spoilFRA();
t = dppop();
s = dppop();
- npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+ wpush((long)(t < s ? 1 : t > s ? -1 : 0));
}
DoTLTz()
/* TLT -: True if less, i.e. iff top of stack < 0 */
LOG(("@T6 DoTLTz()"));
spoilFRA();
- npush((long)(wpop() < 0 ? 1 : 0), wsize);
+ wpush((long)(wpop() < 0 ? 1 : 0));
}
DoTLEz()
/* TLE -: True if less or equal, i.e. iff top of stack <= 0 */
LOG(("@T6 DoTLEz()"));
spoilFRA();
- npush((long)(wpop() <= 0 ? 1 : 0), wsize);
+ wpush((long)(wpop() <= 0 ? 1 : 0));
}
DoTEQz()
/* TEQ -: True if equal, i.e. iff top of stack = 0 */
LOG(("@T6 DoTEQz()"));
spoilFRA();
- npush((long)(wpop() == 0 ? 1 : 0), wsize);
+ wpush((long)(wpop() == 0 ? 1 : 0));
}
DoTNEz()
/* TNE -: True if not equal, i.e. iff top of stack non zero */
LOG(("@T6 DoTNEz()"));
spoilFRA();
- npush((long)(wpop() != 0 ? 1 : 0), wsize);
+ wpush((long)(wpop() != 0 ? 1 : 0));
}
DoTGEz()
/* TGE -: True if greater or equal, i.e. iff top of stack >= 0 */
LOG(("@T6 DoTGEz()"));
spoilFRA();
- npush((long)(wpop() >= 0 ? 1 : 0), wsize);
+ wpush((long)(wpop() >= 0 ? 1 : 0));
}
DoTGTz()
/* TGT -: True if greater, i.e. iff top of stack > 0 */
LOG(("@T6 DoTGTz()"));
spoilFRA();
- npush((long)(wpop() > 0 ? 1 : 0), wsize);
+ wpush((long)(wpop() > 0 ? 1 : 0));
}
/********************************************************
}
}
st_dec(2 * obj_size);
- npush((long) comp_res, wsize);
+ wpush((long) comp_res);
}
f *= 2.0;
fpush((sign) ? -f : f, n); /* push mantissa */
- npush(exponent, wsize); /* push exponent */
+ wpush(exponent); /* push exponent */
}
/* floating point service routines, to avoid having to use -lm */
/* INC -: Increment word on top of stack by 1 (*) */
LOG(("@Z6 DoINCz()"));
spoilFRA();
- npush(inc(spop(wsize)), wsize);
+ wpush(inc(spop(wsize)));
}
DoINLm(arg)
/* DEC -: Decrement word on top of stack by 1 (*) */
LOG(("@Z6 DoDECz()"));
spoilFRA();
- npush(dec(spop(wsize)), wsize);
+ wpush(dec(spop(wsize)));
}
DoDELn2(arg)
LOG(("@Z6 DoZERl2(%ld)", l));
spoilFRA();
for (i = arg_w(l); i; i -= wsize)
- npush(0L, wsize);
+ wpush(0L);
}
DoZERs(hob, wfac)
LOG(("@Z6 DoZERs(%ld)", l));
spoilFRA();
for (i = arg_w(l); i; i -= wsize)
- npush(0L, wsize);
+ wpush(0L);
}
DoZERz()
LOG(("@Z6 DoZERz(%ld)", l));
spoilFRA();
for (i = arg_w(l); i; i -= wsize)
- npush(0L, wsize);
+ wpush(0L);
}
PRIVATE long inc(l)
LOG(("@L6 DoLOCl2(%ld)", l));
spoilFRA();
- npush(arg_c(l), wsize);
+ wpush(arg_c(l));
}
DoLOCl4(arg)
LOG(("@L6 DoLOCl4(%ld)", l));
spoilFRA();
- npush(arg_c(l), wsize);
+ wpush(arg_c(l));
}
DoLOCm(arg)
LOG(("@L6 DoLOCm(%ld)", l));
spoilFRA();
- npush(l, wsize);
+ wpush(l);
}
DoLOCs(hob, wfac)
LOG(("@L6 DoLOCs(%ld)", l));
spoilFRA();
- npush(arg_c(l), wsize);
+ wpush(arg_c(l));
}
DoLDCl2(arg)
/* LIM -: Load 16 bit ignore mask */
LOG(("@M6 DoLIMz()"));
spoilFRA();
- npush(IgnMask, wsize);
+ wpush(IgnMask);
}
DoLINl2(arg)
trap(ESET);
}
}
- test_byte = stack_loc(SP + (bitno / 8));
+ test_byte = stack_loc(SP + (bitno >> 3));
st_dec(w);
- npush((long)((test_byte & BIT(bitno % 8)) ? 1 : 0), wsize);
+ wpush((long)((test_byte & BIT(bitno & 7)) ? 1 : 0));
}
/********************************************************
trap(ESET);
}
}
- st_stn(SP + (bitno / 8), (long)BIT(bitno % 8), 1L);
+ st_stn(SP + (bitno >> 3), (long)BIT(bitno & 7), 1L);
}
PRIVATE std_item(addr)
ptr addr;
{
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_stack(addr, psize)
&& std_bytes(addr, addr + psize, SH_DATAP|SH_INSP)
) {
displ_sh(st_sh(addr), stack_loc(addr))));
}
else
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_stack(addr, wsize)
&& std_bytes(addr, addr + wsize, SH_INT)
) {
PRIVATE FRA_item(addr)
int addr;
{
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_FRA(addr, psize)
&& FRAd_bytes(addr, (int)(addr + psize), SH_DATAP|SH_INSP)
) {
displ_sh(FRA_sh[addr], FRA[addr])));
}
else
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_FRA(addr, wsize)
&& FRAd_bytes(addr, (int)(addr + wsize), SH_INT)
) {
PRIVATE gdad_item(addr)
ptr addr;
{
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_data(addr, psize)
&& dtd_bytes(addr, addr + psize, SH_DATAP|SH_INSP)
) {
displ_sh(dt_sh(addr), data_loc(addr))));
}
else
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_data(addr, wsize)
&& dtd_bytes(addr, addr + wsize, SH_INT)
) {
PRIVATE hpd_item(addr)
ptr addr;
{
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_data(addr, psize)
&& dtd_bytes(addr, addr + psize, SH_DATAP|SH_INSP)
) {
displ_sh(dt_sh(addr), data_loc(addr))));
}
else
- if ( is_aligned(addr, wsize)
+ if ( is_wordaligned(addr)
&& is_in_data(addr, wsize)
&& dtd_bytes(addr, addr + wsize, SH_INT)
) {
long min_off;
long max_off;
ptr max_addr;
+size wsizem1;
/******** EM program parameters ********/
ptr HL;
char *stack;
+char *stackML;
ptr SL;
extern long min_off; /* Minimum offset */
extern long max_off; /* Maximum offset */
extern ptr max_addr; /* Maximum address */
+extern size wsizem1; /* wordsize - 1 */
/******** EM program parameters ********/
extern ptr HL; /* Heap Limit */
extern char *stack; /* stack space and local data */
+extern char *stackML; /* stack + ML, to speed up stack accesses */
extern ptr SL; /* Stack Limit */
}
dt_stdp(vecp, i2p(0)); /* terminating zero */
- npush((long) ac, wsize); /* push argc */
+ wpush((long) ac); /* push argc */
}
PRIVATE size alignedstrlen(s)
#ifdef LOGGING
dt_clear_area(from, to)
ptr from;
- ptr to;
+ register ptr to;
{
/* includes *from but excludes *to */
register ptr a;
st_clear_area(from, to)
ptr from;
- ptr to;
+ register ptr to;
{
/* includes both *from and *to (since ML+1 is unexpressible) */
register ptr a;
for (sn = 0; sn < NSIG+1; sn++) {
/* for all signals that would cause termination */
if (!UNIX_trap(sn)) {
+#ifdef SIGCHLD
+ if (sn == SIGCHLD) continue;
+#endif
+#ifdef SIGIO
+ if (sn == SIGIO) continue;
+#endif
+#ifdef SIGWINCH
+ if (sn == SIGWINCH) continue;
+#endif
if (signal(sn, SIG_IGN) != SIG_IGN) {
/* we take our fate in our own hand */
signal(sn, HndlIntSig);
/******** Memory address & location defines ********/
#define data_loc(a) (*(data + (p2i(a))))
-#define stack_loc(a) (*(stack + (ML - (a))))
+#define stack_loc(a) (*(stackML - (a)))
#define mem_loc(a) (in_stack(a) ? stack_loc(a) : data_loc(a))
#define loc_addr(o) (((o) < 0) ? (LB + (o)) : (AB + (o)))
/******** Checks on adresses and ranges ********/
#define is_aligned(a,n) ((p2i(a)) % (n) == 0)
+#define is_wordaligned(a) (((p2i(a)) & wsizem1) == 0)
#define ch_aligned(a,n) { if (!is_aligned(a, min(n, wsize))) \
{ trap(EBADPTR); } }
+#define ch_wordaligned(a) { if (!is_wordaligned(a)) \
+ { trap(EBADPTR); } }
#define in_gda(p) ((p) < HB)
#define in_stack(p) (SP <= (p) && (p) <= ML)
#define pop_unsp() ((unsigned int) upop(psize))
#define pop_ptr() (dppop())
-#define push_int(a) (npush((long)(a), wsize))
+#define push_int(a) (wpush((long)(a)))
#define push_i2(a) (npush((long)(a), INT2SIZE))
#define push_i4(a) (npush((long)(a), INT4SIZE))
#define push_unsp(a) (npush((long)(a), psize))
fatal("Bad wordsize in loadfile");
dwsize = 2 * wsize; /* set double wordsize */
+ wsizem1 = wsize - 1; /* wordsize - 1 used often */
psize = rd_int(2L);
if (!(psize == 2 || psize == 4) || psize < wsize)
* *
* A double is 8 bytes, so it can contain 4- and 8-byte (EM) *
* floating point numbers. That's why a 4-byte floating point *
- * number is also stored in a double. In this case only the *
- * the 4 LSB's are used. These bytes contain the most important *
- * information, the MSB's are just for precision. *
+ * number is also stored in a double. *
************************************************************************/
PRIVATE ptr rd_repeat(pos, count, prev_pos)
extern char *data_sh; /* shadowbytes of data space */
extern char *stack_sh; /* shadowbytes of stack space */
+extern char *stackML_sh; /* stack_sh + ML (to speed up stack access) */
/* Bit 0, 1, 2 and 3: datatype/pointertype. */
/******** Shadowbytes, general ********/
#define dt_sh(a) (*(data_sh + (p2i(a))))
-#define st_sh(a) (*(stack_sh + (ML - (a))))
+#define st_sh(a) (*(stackML_sh - (a)))
#define mem_sh(a) (in_stack(a) ? st_sh(a) : dt_sh(a))
/******** Shadowbytes settings for data ********/
#ifdef LOGGING
char *stack_sh; /* stadowbytes */
+char *stackML_sh; /* speed up access of stadowbytes */
#endif LOGGING
PRIVATE warn_stbits();
SL = ML + 1 - STACKSIZE; /* initialize Stack Limit */
stack = Malloc(STACKSIZE, "stack space");
+ stackML = stack + ML;
#ifdef LOGGING
stack_sh = Malloc(STACKSIZE, "shadowspace for stack");
+ stackML_sh = stack_sh + ML;
st_clear_area(ML, SL);
#endif LOGGING
}
if (LB < p) {
wtrap(WSPGTLB, ESTACK);
}
- if (p < HP) {
- wtrap(WSPINHEAP, ESTACK);
- }
- if (!is_aligned(p, wsize)) {
+ if (!is_wordaligned(p)) {
wtrap(WSPODD, ESTACK);
}
- if (maxstack) {
- /* more than allowed on command line */
- if (ML - p > maxstack) {
- warning(WESTACK);
- trap(ESTACK);
+ if (p < SP) {
+ if (p < HP) {
+ wtrap(WSPINHEAP, ESTACK);
}
- }
- if (p < SL) {
- /* extend stack space */
- register size stacksize = ML + 1 - p;
-
- stacksize = allocfrac(stacksize);
- SL = ML + 1 - stacksize;
- stack = Realloc(stack, (size)(stacksize), "stack space");
+ if (maxstack) {
+ /* more than allowed on command line */
+ if (ML - p > maxstack) {
+ warning(WESTACK);
+ trap(ESTACK);
+ }
+ }
+ if (p < SL) {
+ /* extend stack space */
+ register size stacksize = ML + 1 - p;
+
+ stacksize = allocfrac(stacksize);
+ SL = ML + 1 - stacksize;
+ stack = Realloc(stack, (size)(stacksize), "stack space");
+ stackML = stack + ML;
#ifdef LOGGING
- stack_sh = Realloc(stack_sh, (size)(stacksize),
+ stack_sh = Realloc(stack_sh, (size)(stacksize),
"shadowspace for stack");
+ stackML_sh = stack_sh + ML;
#endif LOGGING
- }
+ }
#ifdef LOGGING
- if (!in_stack(p)) {
st_clear_area(SP - 1, p);
- }
#endif LOGGING
+ }
SP = p;
}
if (!in_stack(p)) {
wtrap(WLBOUT, ESTACK);
}
- if (!is_aligned(p, wsize)) {
+ if (!is_wordaligned(p)) {
wtrap(WLBODD, ESTACK);
}
if (!is_LB(p)) {
************************************************************************/
st_stdp(addr, ap)
- ptr addr, ap;
+ register ptr addr;
+ ptr ap;
{
register int i;
register long p = (long) ap;
LOG(("@s6 st_stdp(%lu, %lu)", addr, p));
ch_in_stack(addr, psize);
- ch_aligned(addr, wsize);
- for (i = 0; i < (int) psize; i++) {
- ch_st_prot(addr + i);
- stack_loc(addr + i) = (char) (p);
- st_dp(addr + i);
+ ch_wordaligned(addr);
+ for (i = (int) psize; i > 0; i--, addr++) {
+ ch_st_prot(addr);
+ stack_loc(addr) = (char) (p);
+ st_dp(addr);
p = p>>8;
}
}
st_stip(addr, ap)
- ptr addr, ap;
+ register ptr addr;
+ ptr ap;
{
register int i;
register long p = (long) ap;
LOG(("@s6 st_stip(%lu, %lu)", addr, p));
ch_in_stack(addr, psize);
- ch_aligned(addr, wsize);
- for (i = 0; i < (int) psize; i++) {
- ch_st_prot(addr + i);
- stack_loc(addr + i) = (char) (p);
- st_ip(addr + i);
+ ch_wordaligned(addr);
+ for (i = (int) psize; i > 0; i--, addr++) {
+ ch_st_prot(addr);
+ stack_loc(addr) = (char) (p);
+ st_ip(addr);
p = p>>8;
}
}
st_stn(addr, al, n)
- ptr addr;
+ register ptr addr;
long al;
size n;
{
register int i;
register long l = al;
+#ifdef LOGGING
+ /* a psize zero is ambiguous */
+ int sh_flags = (l == 0 && n == psize) ? (SH_INT|SH_DATAP) : SH_INT;
+#endif
LOG(("@s6 st_stn(%lu, %ld, %lu)", addr, l, n));
ch_in_stack(addr, n);
ch_aligned(addr, n);
/* store the bytes */
- for (i = 0; i < (int) n; i++) {
- ch_st_prot(addr + i);
- stack_loc(addr + i) = (char) l;
+ for (i = (int) n; i > 0; i--, addr++) {
+ ch_st_prot(addr);
+ stack_loc(addr) = (char) l;
#ifdef LOGGING
- if (al == 0 && n == psize) {
- /* a psize zero, ambiguous */
- st_sh(addr + i) = (SH_INT|SH_DATAP);
- }
- else {
- st_sh(addr + i) = SH_INT;
- }
+ st_sh(addr) = sh_flags;
#endif LOGGING
l = l>>8;
}
#ifndef NOFLOAT
st_stf(addr, f, n)
- ptr addr;
+ register ptr addr;
double f;
size n;
{
register char *cp = (char *) &f;
+ float fl;
register int i;
LOG(("@s6 st_stf(%lu, %g, %lu)", addr, f, n));
ch_in_stack(addr, n);
- ch_aligned(addr, wsize);
- for (i = 0; i < (int) n; i++) {
- ch_st_prot(addr + i);
- stack_loc(addr + i) = *(cp++);
- st_fl(addr + i);
+ ch_wordaligned(addr);
+ if ((int) n == 4) {
+ fl = f;
+ cp = (char *) &fl;
+ }
+ for (i = (int) n; i > 0; i--, addr++) {
+ ch_st_prot(addr);
+ stack_loc(addr) = *(cp++);
+ st_fl(addr);
}
}
#endif NOFLOAT
************************************************************************/
ptr st_lddp(addr)
- ptr addr;
+ register ptr addr;
{
register ptr p;
LOG(("@s6 st_lddp(%lu)", addr));
ch_in_stack(addr, psize);
- ch_aligned(addr, wsize);
+ ch_wordaligned(addr);
#ifdef LOGGING
if (!is_st_set(addr, psize, SH_DATAP)) {
warning(WLDPEXP);
}
ptr st_ldip(addr)
- ptr addr;
+ register ptr addr;
{
register ptr p;
LOG(("@s6 st_ldip(%lu)", addr));
ch_in_stack(addr, psize);
- ch_aligned(addr, wsize);
+ ch_wordaligned(addr);
#ifdef LOGGING
if (!is_st_set(addr, psize, SH_INSP)) {
warning(WLIPEXP);
}
unsigned long st_ldu(addr, n)
- ptr addr;
+ register ptr addr;
size n;
{
register int i;
}
long st_lds(addr, n)
- ptr addr;
+ register ptr addr;
size n;
{
register int i;
#ifndef NOFLOAT
double st_ldf(addr, n)
- ptr addr;
+ register ptr addr;
size n;
{
- double f = 0.0;
- register char *cp = (char *) &f;
+ double f;
+ float fl;
+ register char *cp;
register int i;
LOG(("@s6 st_ldf(%lu, %lu)", addr, n));
+ if ((int)n == 4) {
+ cp = (char *) &fl;
+ }
+ else {
+ cp = (char *) &f;
+ }
ch_in_stack(addr, n);
- ch_aligned(addr, wsize);
+ ch_wordaligned(addr);
#ifdef LOGGING
if (!is_st_set(addr, n, SH_FLOAT)) {
warning(WLFEXP);
}
#endif LOGGING
- for (i = 0; i < (int) n; i++) {
- *(cp++) = stack_loc(addr + i);
+ for (i = (int) n; i > 0; i--, addr++) {
+ *(cp++) = stack_loc(addr);
+ }
+ if ((int)n == 4) {
+ f = fl;
}
return (f);
}
************************************************************************/
st_mvs(s2, s1, n) /* s1 -> s2 */
- ptr s2, s1;
+ register ptr s2, s1;
size n;
{
register int i;
ch_in_stack(s1, n);
- ch_aligned(s1, wsize);
+ ch_wordaligned(s1);
ch_in_stack(s2, n);
- ch_aligned(s2, wsize);
+ ch_wordaligned(s2);
- for (i = 0; i < (int) n; i++) {
- ch_st_prot(s2 + i);
- ch_st_prot(s1 + i);
- stack_loc(s2 + i) = stack_loc(s1 + i);
+ for (i = (int) n; i > 0; i--, s1++, s2++) {
+ ch_st_prot(s2);
+ ch_st_prot(s1);
+ stack_loc(s2) = stack_loc(s1);
#ifdef LOGGING
- st_sh(s2 + i) = st_sh(s1 + i) & ~SH_PROT;
+ st_sh(s2) = st_sh(s1) & ~SH_PROT;
#endif LOGGING
}
}
st_mvd(s, d, n) /* d -> s */
- ptr s, d;
+ register ptr s, d;
size n;
{
register int i;
ch_in_data(d, n);
- ch_aligned(d, wsize);
+ ch_wordaligned(d);
ch_in_stack(s, n);
- ch_aligned(s, wsize);
+ ch_wordaligned(s);
- for (i = 0; i < (int) n; i++) {
- ch_st_prot(s + i);
- stack_loc(s + i) = data_loc(d + i);
+ for (i = (int) n; i > 0; i--, s++, d++) {
+ ch_st_prot(s);
+ stack_loc(s) = data_loc(d);
#ifdef LOGGING
- st_sh(s + i) = dt_sh(d + i) & ~SH_PROT;
+ st_sh(s) = dt_sh(d) & ~SH_PROT;
#endif LOGGING
}
}
************************************************************************
* *
* dppush(p) - push a data ptr, load from p. *
+ * wpush(l) - push a word, load from l. *
* npush(l, n) - push n bytes, load from l. *
* push_dt(d, n) - push n bytes, load from address d in data. *
* push_st(s, n) - push n bytes, load from address s in stack. *
st_stdp(SP, p);
}
-npush(l, n)
+wpush(l)
long l;
+{
+ st_inc(wsize);
+ st_stn(SP, l, wsize);
+}
+
+npush(l, n)
+ register long l;
size n;
{
- st_inc(max(n, wsize));
+ size m = max(n, wsize);
+
+ st_inc(m);
if (n == 1)
l &= MASK1;
else
if (n == 2)
l &= MASK2;
- st_stn(SP, l, max(n, wsize));
+ st_stn(SP, l, m);
}
#ifdef LOGGING
PRIVATE warn_stbits(addr, n)
- ptr addr;
- size n;
+ register ptr addr;
+ register size n;
{
register int or_bits = 0;
register int and_bits = 0xff;
************************************************************************/
newPC(p)
- ptr p;
+ register ptr p;
{
register struct proc *pr = &proctab[PI];
#define arg_n(u) ((u > i_maxuw) ? (wtrap(WARGL, EILLINS), 0) : u)
-#define arg_s(s) ((s <= 0 || s > max_off || s % wsize) ? \
+#define arg_s(s) ((s <= 0 || s > max_off || (s & wsizem1)) ? \
(trap(EODDZ), s) : s)
-#define arg_z(s) ((s < 0 || s > max_off || s % wsize) ? \
+#define arg_z(s) ((s < 0 || s > max_off || (s & wsizem1)) ? \
(trap(EODDZ), s) : s)
-#define arg_o(s) ((s < 0 || s > max_off || (s%wsize && wsize%s)) ? \
+#define arg_o(s) ((s < 0 || s > max_off || ((s&wsizem1) && wsize%s)) ? \
(trap(EODDZ), s) : s)
-#define arg_w(s) ((s <= 0 || s > max_off || s % wsize) ? \
+#define arg_w(s) ((s <= 0 || s > max_off || (s & wsizem1)) ? \
(trap(EODDZ), s) : s)
#define arg_p(l) ((l >= NProc) ? (wtrap(WARGP, EILLINS), 0) : l)
#define arg_wf(s) ((s != 4 && s != 8) ? (trap(EODDZ), s) : s)
-#define arg_wi(s) (((s != 2 && s != 4) || (s % wsize)) ? \
+#define arg_wi(s) (((s != 2 && s != 4) || (s & wsizem1)) ? \
(trap(EODDZ), s) : s)
/* special tests */
/* save the Function Return Area */
pushFRA(FRASize);
- npush((long)FRASize, wsize);
- npush((long)FRA_def, wsize);
+ wpush((long)FRASize);
+ wpush((long)FRA_def);
/* set up the trap number as the only parameter */
- npush((long) nr, wsize);
+ wpush((long) nr);
tpi = TrapPI; /* allowed since OnTrap == TR_TRAP */
TrapPI = 0;