2019-03-17 14:42:00 +00:00
|
|
|
/** \file
|
|
|
|
Stack manipulation routines.
|
1988-06-22 16:57:09 +00:00
|
|
|
*/
|
|
|
|
|
1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
#include "em_abs.h"
|
1988-06-22 16:57:09 +00:00
|
|
|
#include "logging.h"
|
|
|
|
#include "nofloat.h"
|
|
|
|
#include "global.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "warn.h"
|
|
|
|
#include "trap.h"
|
|
|
|
#include "alloc.h"
|
|
|
|
#include "memdirect.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "shadow.h"
|
2019-03-17 14:42:00 +00:00
|
|
|
#include "stack.h"
|
|
|
|
#include "data.h"
|
1988-06-22 16:57:09 +00:00
|
|
|
#include "rsb.h"
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** initial stack size in bytes */
|
|
|
|
#define STACKSIZE 1000L
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
extern size maxstack; /* from main.c */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
char *stack_sh; /* stadowbytes */
|
|
|
|
char *stackML_sh; /* speed up access of stadowbytes */
|
|
|
|
PRIVATE void st_clear_area(ptr, ptr);
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
PRIVATE void warn_stbits(ptr, size);
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Initialize and allocate the operand stack space "stack". */
|
|
|
|
void init_stack(void)
|
|
|
|
{
|
|
|
|
ML = max_addr; /* set Memory Limit */
|
|
|
|
SP = ML + 1; /* initialize Stack Pointer */
|
|
|
|
SL = ML + 1; /* initialize Stack Limit */
|
|
|
|
LB = ML + 1; /* initialize Local Base */
|
|
|
|
AB = ML + 1; /* initialize Actual Base */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
SL = ML + 1 - STACKSIZE; /* initialize Stack Limit */
|
1988-06-22 16:57:09 +00:00
|
|
|
stack = Malloc(STACKSIZE, "stack space");
|
1989-11-13 15:36:12 +00:00
|
|
|
stackML = stack + ML;
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
|
|
|
stack_sh = Malloc(STACKSIZE, "shadowspace for stack");
|
1989-11-13 15:36:12 +00:00
|
|
|
stackML_sh = stack_sh + ML;
|
1988-06-22 16:57:09 +00:00
|
|
|
st_clear_area(ML, SL);
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* EM-register division. *
|
|
|
|
************************************************************************
|
|
|
|
* *
|
|
|
|
* newSP(p) - check and adjust StackPointer. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* incSP(n) - increment stack pointer. n already checked *
|
|
|
|
* decSP(n) - decrement stack pointer. n already checked *
|
1988-06-22 16:57:09 +00:00
|
|
|
* newLB(p) - check and adjust Local Base and Actual Base *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Set the value of the stack pointer "SP" to the value "ap".
|
|
|
|
* Full validation of the new value is done beforehand.
|
|
|
|
*/
|
|
|
|
void newSP(ptr ap)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register ptr p = ap;
|
2019-03-17 14:42:00 +00:00
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
LOG(("@s6 newSP(%lu), ML = %lu, SP = %lu", p, ML, SP));
|
2019-03-17 14:42:00 +00:00
|
|
|
if (LB < p)
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
wtrap(WSPGTLB, ESTACK);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_wordaligned(p))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
wtrap(WSPODD, ESTACK);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if (p < SP)
|
|
|
|
{
|
|
|
|
if (p < HP)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
wtrap(WSPINHEAP, ESTACK);
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if (maxstack)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
/* more than allowed on command line */
|
2019-03-17 14:42:00 +00:00
|
|
|
if (ML - p > maxstack)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
warning(WESTACK);
|
|
|
|
trap(ESTACK);
|
|
|
|
}
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if (p < SL)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
/* extend stack space */
|
|
|
|
register size stacksize = ML + 1 - p;
|
|
|
|
|
|
|
|
stacksize = allocfrac(stacksize);
|
|
|
|
SL = ML + 1 - stacksize;
|
2019-03-17 14:42:00 +00:00
|
|
|
stack = Realloc(stack, (size) (stacksize), "stack space");
|
1989-11-13 15:36:12 +00:00
|
|
|
stackML = stack + ML;
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
stack_sh = Realloc(stack_sh, (size) (stacksize),
|
|
|
|
"shadowspace for stack");
|
1989-11-13 15:36:12 +00:00
|
|
|
stackML_sh = stack_sh + ML;
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1989-11-13 15:36:12 +00:00
|
|
|
}
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#ifdef LOGGING
|
|
|
|
st_clear_area(SP - 1, p);
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1989-11-13 15:36:12 +00:00
|
|
|
}
|
1988-06-22 16:57:09 +00:00
|
|
|
SP = p;
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Increment stack pointer "SP" by "n" bytes.
|
|
|
|
* Full validation on stack alignment and address is done.
|
|
|
|
*/
|
|
|
|
void incSP(size n)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register ptr p = SP - n;
|
2019-03-17 14:42:00 +00:00
|
|
|
|
|
|
|
if (p < HP || maxstack || p < SL)
|
|
|
|
newSP(p);
|
|
|
|
else
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
LOG(("@s6 newSP(%lu), ML = %lu, SP = %lu", p, ML, SP));
|
|
|
|
#ifdef LOGGING
|
|
|
|
/* inline version of st_clear_area.
|
2019-03-17 14:42:00 +00:00
|
|
|
*/
|
1989-11-22 13:38:37 +00:00
|
|
|
SP = p;
|
|
|
|
{
|
2019-03-17 14:42:00 +00:00
|
|
|
while (n--)
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
st_undef(p);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Decrement stack pointer "SP" by "n" bytes.
|
|
|
|
* Full validation on stack alignment and address is done.
|
|
|
|
*/
|
|
|
|
void decSP(size n)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register ptr p = SP + n;
|
2019-03-17 14:42:00 +00:00
|
|
|
|
|
|
|
if (LB < p)
|
|
|
|
newSP(p);
|
|
|
|
else
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
LOG(("@s6 newSP(%lu), ML = %lu, SP = %lu", p, ML, SP));
|
|
|
|
SP = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
void newLB(ptr p)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!in_stack(p))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
wtrap(WLBOUT, ESTACK);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_wordaligned(p))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
wtrap(WLBODD, ESTACK);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_LB(p))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
wtrap(WLBRSB, ESTACK);
|
|
|
|
}
|
|
|
|
LB = p;
|
|
|
|
AB = LB + rsbsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Stack store division. *
|
|
|
|
************************************************************************
|
|
|
|
* *
|
|
|
|
* st_stdp(addr, p) - STore Data Pointer. *
|
|
|
|
* st_stip(addr, p) - STore Instruction Pointer. *
|
|
|
|
* st_stn(addr, l, n) - STore N byte integer. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* st_stw(addr, l) - STore wordsize integer. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* st_stf(addr, f, n) - STore Floating point number. *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Store data pointer "ap" in stack at address "addr".
|
|
|
|
* Full validation is done on "addr" before storing into it.
|
|
|
|
*/
|
|
|
|
void st_stdp(register ptr addr, ptr ap)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register long p = (long) ap;
|
|
|
|
|
|
|
|
LOG(("@s6 st_stdp(%lu, %lu)", addr, p));
|
|
|
|
ch_in_stack(addr, psize);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(addr);
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) psize; i > 0; i--, addr++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_st_prot(addr);
|
|
|
|
stack_loc(addr) = (char) (p);
|
|
|
|
st_dp(addr);
|
2019-03-17 14:42:00 +00:00
|
|
|
p = p >> 8;
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Store code pointer "ap" in stack address "addr".
|
|
|
|
* Full validation is done on "addr" before storing into it.
|
|
|
|
*/
|
|
|
|
void st_stip(register ptr addr, ptr ap)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register long p = (long) ap;
|
|
|
|
|
|
|
|
LOG(("@s6 st_stip(%lu, %lu)", addr, p));
|
|
|
|
ch_in_stack(addr, psize);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(addr);
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) psize; i > 0; i--, addr++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_st_prot(addr);
|
|
|
|
stack_loc(addr) = (char) (p);
|
|
|
|
st_ip(addr);
|
2019-03-17 14:42:00 +00:00
|
|
|
p = p >> 8;
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Store an integer value "al" of "n" bytes in size in stack at address "addr".
|
|
|
|
* Full validation is done on "addr" before storing into it.
|
|
|
|
*/
|
|
|
|
void st_stn(register ptr addr, long al, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register long l = al;
|
1989-11-13 15:36:12 +00:00
|
|
|
#ifdef LOGGING
|
|
|
|
/* a psize zero is ambiguous */
|
2019-03-17 14:42:00 +00:00
|
|
|
int sh_flags = (l == 0 && n == psize) ? (SH_INT | SH_DATAP) : SH_INT;
|
1989-11-13 15:36:12 +00:00
|
|
|
#endif
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
LOG(("@s6 st_stn(%lu, %ld, %lu)", addr, l, n));
|
|
|
|
ch_in_stack(addr, n);
|
|
|
|
ch_aligned(addr, n);
|
|
|
|
|
|
|
|
/* store the bytes */
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) n; i > 0; i--, addr++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_st_prot(addr);
|
|
|
|
stack_loc(addr) = (char) l;
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
1989-11-13 15:36:12 +00:00
|
|
|
st_sh(addr) = sh_flags;
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
2019-03-17 14:42:00 +00:00
|
|
|
l = l >> 8;
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Store an integer value "al" of word size bytes in stack at address "addr".
|
|
|
|
* Full validation is done on "addr" before storing into it.
|
|
|
|
*/
|
|
|
|
void st_stw(register ptr addr, long al)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register long l = al;
|
|
|
|
#ifdef LOGGING
|
|
|
|
/* a psize zero is ambiguous */
|
2019-03-17 14:42:00 +00:00
|
|
|
int sh_flags = (l == 0 && wsize == psize) ? (SH_INT | SH_DATAP) : SH_INT;
|
1989-11-22 13:38:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
LOG(("@s6 st_stw(%lu, %ld)", addr, l));
|
|
|
|
ch_w_in_stack(addr);
|
|
|
|
ch_wordaligned(addr);
|
|
|
|
|
|
|
|
/* store the bytes */
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) wsize; i > 0; i--, addr++)
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
ch_st_prot(addr);
|
|
|
|
stack_loc(addr) = (char) l;
|
|
|
|
#ifdef LOGGING
|
|
|
|
st_sh(addr) = sh_flags;
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
2019-03-17 14:42:00 +00:00
|
|
|
l = l >> 8;
|
1989-11-22 13:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifndef NOFLOAT
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Store a real value "f" of "n" bytes in size in stack at address "addr".
|
|
|
|
* Full validation is done on "addr" before storing into it.
|
|
|
|
*/
|
|
|
|
void st_stf(register ptr addr, double f, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register char *cp = (char *) &f;
|
1989-11-13 15:36:12 +00:00
|
|
|
float fl;
|
1988-06-22 16:57:09 +00:00
|
|
|
register int i;
|
|
|
|
|
|
|
|
LOG(("@s6 st_stf(%lu, %g, %lu)", addr, f, n));
|
|
|
|
ch_in_stack(addr, n);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(addr);
|
2019-03-17 14:42:00 +00:00
|
|
|
if ((int) n == 4)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
fl = f;
|
|
|
|
cp = (char *) &fl;
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) n; i > 0; i--, addr++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_st_prot(addr);
|
|
|
|
stack_loc(addr) = *(cp++);
|
|
|
|
st_fl(addr);
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* NOFLOAT */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Stack load division. *
|
|
|
|
************************************************************************
|
|
|
|
* *
|
|
|
|
* st_lddp(addr) - LoaD Data Pointer from stack. *
|
|
|
|
* st_ldip(addr) - LoaD Instruction Pointer from stack. *
|
|
|
|
* st_ldu(addr, n) - LoaD n Unsigned bytes from stack. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* st_lduw(addr) - LoaD wsize Unsigned bytes from stack. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* st_lds(addr, n) - LoaD n Signed bytes from stack. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* st_ldsw(addr) - LoaD wsize Signed bytes from stack. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* st_ldf(addr, n) - LoaD Floating point number from stack. *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns a data pointer stored on the stack
|
|
|
|
* at address "addr".
|
|
|
|
*/
|
|
|
|
ptr st_lddp(register ptr addr)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register ptr p;
|
|
|
|
|
|
|
|
LOG(("@s6 st_lddp(%lu)", addr));
|
|
|
|
|
|
|
|
ch_in_stack(addr, psize);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(addr);
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, psize, SH_DATAP))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
warning(WLDPEXP);
|
|
|
|
warn_stbits(addr, psize);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
p = p_in_stack(addr);
|
|
|
|
LOG(("@s6 st_lddp() returns %lu", p));
|
|
|
|
return (p);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns a core pointer stored on the stack
|
|
|
|
* at address "addr".
|
|
|
|
*/
|
|
|
|
ptr st_ldip(register ptr addr)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register ptr p;
|
|
|
|
|
|
|
|
LOG(("@s6 st_ldip(%lu)", addr));
|
|
|
|
|
|
|
|
ch_in_stack(addr, psize);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(addr);
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, psize, SH_INSP))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
warning(WLIPEXP);
|
|
|
|
warn_stbits(addr, psize);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
p = p_in_stack(addr);
|
|
|
|
LOG(("@s6 st_ldip() returns %lu", p));
|
|
|
|
return (p);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns an unsigned integer value of
|
|
|
|
* "n" bytes in size stored in the stack at address
|
|
|
|
* "addr".
|
|
|
|
*/
|
|
|
|
unsigned long st_ldu(register ptr addr, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register unsigned long u = 0;
|
|
|
|
|
|
|
|
LOG(("@s6 st_ldu(%lu, %lu)", addr, n));
|
|
|
|
|
|
|
|
ch_in_stack(addr, n);
|
|
|
|
ch_aligned(addr, n);
|
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, n, SH_INT))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
warning(n == 1 ? WLCEXP : WLIEXP);
|
|
|
|
warn_stbits(addr, n);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
addr += n - 1;
|
|
|
|
for (i = (int) n - 1; i >= 0; i--, addr--)
|
|
|
|
{
|
|
|
|
u = (u << 8) | (btou(stack_loc(addr)));
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
LOG(("@s6 st_ldu() returns %ld", u));
|
|
|
|
return (u);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns an unsigned integer value of
|
|
|
|
* word size bytes stored in the stack at address
|
|
|
|
* "addr".
|
|
|
|
*/
|
|
|
|
unsigned long st_lduw(register ptr addr)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register unsigned long u = 0;
|
|
|
|
|
|
|
|
LOG(("@s6 st_lduw(%lu)", addr));
|
|
|
|
|
|
|
|
ch_w_in_stack(addr);
|
|
|
|
ch_wordaligned(addr);
|
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, wsize, SH_INT))
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
warning(WLIEXP);
|
|
|
|
warn_stbits(addr, wsize);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1989-11-22 13:38:37 +00:00
|
|
|
|
|
|
|
addr += wsize - 1;
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) wsize - 1; i >= 0; i--, addr--)
|
|
|
|
{
|
|
|
|
u = (u << 8) | (btou(stack_loc(addr)));
|
1989-11-22 13:38:37 +00:00
|
|
|
}
|
|
|
|
LOG(("@s6 st_lduw() returns %ld", u));
|
|
|
|
return (u);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns a signed integer value of
|
|
|
|
* "n" bytes in size stored in the stack at address
|
|
|
|
* "addr".
|
|
|
|
*/
|
|
|
|
long st_lds(register ptr addr, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register long l;
|
|
|
|
|
|
|
|
LOG(("@s6 st_lds(%lu, %lu)", addr, n));
|
|
|
|
|
|
|
|
ch_in_stack(addr, n);
|
|
|
|
ch_aligned(addr, n);
|
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, n, SH_INT))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
warning(n == 1 ? WLCEXP : WLIEXP);
|
|
|
|
warn_stbits(addr, n);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
1989-11-22 13:38:37 +00:00
|
|
|
addr += n - 2;
|
|
|
|
l = btos(stack_loc(addr + 1));
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = n - 2; i >= 0; i--, addr--)
|
|
|
|
{
|
|
|
|
l = (l << 8) | btol(stack_loc(addr));
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
LOG(("@s6 st_lds() returns %ld", l));
|
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns a signed integer value of
|
|
|
|
* word size bytes stored in the stack at address
|
|
|
|
* "addr".
|
|
|
|
*/
|
|
|
|
long st_ldsw(register ptr addr)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register long l;
|
|
|
|
|
|
|
|
LOG(("@s6 st_ldsw(%lu)", addr));
|
|
|
|
|
|
|
|
ch_w_in_stack(addr);
|
|
|
|
ch_wordaligned(addr);
|
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, wsize, SH_INT))
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
warning(WLIEXP);
|
|
|
|
warn_stbits(addr, wsize);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1989-11-22 13:38:37 +00:00
|
|
|
|
|
|
|
addr += wsize - 2;
|
|
|
|
l = btos(stack_loc(addr+1));
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = wsize - 2; i >= 0; i--, addr--)
|
|
|
|
{
|
|
|
|
l = (l << 8) | btol(stack_loc(addr));
|
1989-11-22 13:38:37 +00:00
|
|
|
}
|
|
|
|
LOG(("@s6 st_ldsw() returns %ld", l));
|
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifndef NOFLOAT
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Loads and returns a real value of "n" bytes
|
|
|
|
* stored in the stack at address "addr".
|
|
|
|
*/
|
|
|
|
double st_ldf(register ptr addr, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
double f;
|
|
|
|
float fl;
|
|
|
|
register char *cp;
|
1988-06-22 16:57:09 +00:00
|
|
|
register int i;
|
|
|
|
|
|
|
|
LOG(("@s6 st_ldf(%lu, %lu)", addr, n));
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
if ((int) n == 4)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
cp = (char *) &fl;
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
else
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
cp = (char *) &f;
|
|
|
|
}
|
1988-06-22 16:57:09 +00:00
|
|
|
ch_in_stack(addr, n);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(addr);
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
2019-03-17 14:42:00 +00:00
|
|
|
if (!is_st_set(addr, n, SH_FLOAT))
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
warning(WLFEXP);
|
|
|
|
warn_stbits(addr, n);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) n; i > 0; i--, addr++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
*(cp++) = stack_loc(addr);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
if ((int) n == 4)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
f = fl;
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
return (f);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* NOFLOAT */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Stack move division *
|
|
|
|
************************************************************************
|
|
|
|
* *
|
|
|
|
* st_mvs(s2, s1, n) - Move n bytes in stack from s1 to s2. *
|
|
|
|
* st_mvd(s, d, n) - Move n bytes from d in data to s in stack. *
|
|
|
|
* *
|
|
|
|
* st_mvs(): The intention is to copy the contents of addresses *
|
|
|
|
* s1, s1+1....s1-(n-1) to addresses s2, s2+1....s2+(n-1). *
|
|
|
|
* All addresses are expected to be in the stack. This condition *
|
|
|
|
* is checked for. The shadow bytes of the bytes to be filled in, *
|
|
|
|
* are marked identical to the source-shadow bytes. *
|
|
|
|
* *
|
|
|
|
* st_mvd(), dt_mvd() and dt_mvs() act identically (see data.c). *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Moves "n" bytes from stack address "s1" to
|
|
|
|
* stack address "s2".
|
|
|
|
*/
|
|
|
|
void st_mvs(register ptr s2, register ptr s1, size n)
|
|
|
|
/* s1 -> s2 */
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
ch_in_stack(s1, n);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(s1);
|
1988-06-22 16:57:09 +00:00
|
|
|
ch_in_stack(s2, n);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(s2);
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) n; i > 0; i--, s1++, s2++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_st_prot(s2);
|
|
|
|
ch_st_prot(s1);
|
|
|
|
stack_loc(s2) = stack_loc(s1);
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
1989-11-13 15:36:12 +00:00
|
|
|
st_sh(s2) = st_sh(s1) & ~SH_PROT;
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Move "n" bytes from data pointer "d" to
|
|
|
|
* stack address "s".
|
|
|
|
*/
|
|
|
|
void st_mvd(ptr s, ptr d, size n)
|
|
|
|
/* d -> s */
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
ch_in_data(d, n);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(d);
|
1988-06-22 16:57:09 +00:00
|
|
|
ch_in_stack(s, n);
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_wordaligned(s);
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
for (i = (int) n; i > 0; i--, s++, d++)
|
|
|
|
{
|
1989-11-13 15:36:12 +00:00
|
|
|
ch_st_prot(s);
|
|
|
|
stack_loc(s) = data_loc(d);
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef LOGGING
|
1989-11-13 15:36:12 +00:00
|
|
|
st_sh(s) = dt_sh(d) & ~SH_PROT;
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Stack pop division. *
|
|
|
|
************************************************************************
|
|
|
|
* *
|
|
|
|
* dppop() - pop a data ptr, return a ptr. *
|
|
|
|
* upop(n) - pop n unsigned bytes, return a long. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* uwpop() - pop wsize unsigned bytes, return a long. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* spop(n) - pop n signed bytes, return a long. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* swpop() - pop wsize signed bytes, return a long. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* pop_dt(d, n) - pop n bytes, store at address d in data. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* popw_dt(d) - pop wsize bytes, store at address d in data. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* pop_st(s, n) - pop n bytes, store at address s in stack. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* popw_st(s) - pop wsize bytes, store at address s in stack. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* fpop() - pop a floating point number. *
|
|
|
|
* wpop() - pop a signed word, don't care about any type. *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop and return as a data pointer from the stack. */
|
|
|
|
ptr dppop(void)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register ptr p;
|
|
|
|
|
|
|
|
p = st_lddp(SP);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(psize);
|
1988-06-22 16:57:09 +00:00
|
|
|
LOG(("@s7 dppop(), return: %lu", p));
|
|
|
|
return (p);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop and return as an unsigned integer "n" bytes from the stack. */
|
|
|
|
unsigned long upop(size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register unsigned long l;
|
|
|
|
|
|
|
|
l = st_ldu(SP, n);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(max(n, wsize));
|
1988-06-22 16:57:09 +00:00
|
|
|
LOG(("@s7 upop(), return: %lu", l));
|
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop and return a word size unsigned integer from the stack. */
|
|
|
|
unsigned long uwpop(void)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register unsigned long l;
|
|
|
|
|
|
|
|
l = st_lduw(SP);
|
|
|
|
decSP(wsize);
|
|
|
|
LOG(("@s7 uwpop(), return: %lu", l));
|
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop and return as an integer "n" bytes from the stack. */
|
|
|
|
long spop(size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register long l;
|
|
|
|
|
|
|
|
l = st_lds(SP, n);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(max(n, wsize));
|
1988-06-22 16:57:09 +00:00
|
|
|
LOG(("@s7 spop(), return: %ld", l));
|
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop and return a word size signed integer from the stack. */
|
|
|
|
long swpop(void)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
register long l;
|
|
|
|
|
|
|
|
l = st_ldsw(SP);
|
|
|
|
decSP(wsize);
|
|
|
|
LOG(("@s7 swpop(), return: %ld", l));
|
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop "n" bytes from the stack and store them at data pointer
|
|
|
|
* address "d".
|
|
|
|
*/
|
|
|
|
void pop_dt(ptr d, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
if (n < wsize)
|
|
|
|
dt_stn(d, (long) upop(n), n);
|
2019-03-17 14:42:00 +00:00
|
|
|
else
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
dt_mvs(d, SP, n);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(n);
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop word size bytes from the stack and store them at data pointer
|
|
|
|
* address "d".
|
|
|
|
*/
|
|
|
|
void popw_dt(ptr d)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
dt_mvs(d, SP, wsize);
|
|
|
|
decSP(wsize);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop "n" bytes from the stack and store them at stack address "s". */
|
|
|
|
void pop_st(ptr s, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
if (n < wsize)
|
|
|
|
st_stn(s, (long) upop(n), n);
|
2019-03-17 14:42:00 +00:00
|
|
|
else
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
st_mvs(s, SP, n);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(n);
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop word size bytes from the stack and store them at stack
|
|
|
|
* address "s".
|
|
|
|
*/
|
|
|
|
void popw_st(ptr s)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
st_mvs(s, SP, wsize);
|
|
|
|
decSP(wsize);
|
|
|
|
}
|
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifndef NOFLOAT
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop a real value of "n" bytes from the stack. */
|
|
|
|
double fpop(size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
double d;
|
|
|
|
|
|
|
|
d = st_ldf(SP, n);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(n);
|
1988-06-22 16:57:09 +00:00
|
|
|
return (d);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* NOFLOAT */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Pop a word size value, independently of its type. */
|
|
|
|
long wpop(void)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register long l;
|
2019-03-17 14:42:00 +00:00
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
l = w_in_stack(SP);
|
1989-11-22 13:38:37 +00:00
|
|
|
decSP(wsize);
|
1988-06-22 16:57:09 +00:00
|
|
|
return (l);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Stack push division. *
|
|
|
|
************************************************************************
|
|
|
|
* *
|
|
|
|
* dppush(p) - push a data ptr, load from p. *
|
1989-11-13 15:36:12 +00:00
|
|
|
* wpush(l) - push a word, load from l. *
|
1988-06-22 16:57:09 +00:00
|
|
|
* npush(l, n) - push n bytes, load from l. *
|
|
|
|
* push_dt(d, n) - push n bytes, load from address d in data. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* pushw_dt(d) - push wsize bytes, load from address d in data.*
|
1988-06-22 16:57:09 +00:00
|
|
|
* push_st(s, n) - push n bytes, load from address s in stack. *
|
1989-11-22 13:38:37 +00:00
|
|
|
* pushw_st(s) - push wsize bytes, load from address s in stack.*
|
1988-06-22 16:57:09 +00:00
|
|
|
* fpush(f, n) - push a floating point number, of size n. *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push a data pointer "p" unto the stack. */
|
|
|
|
void dppush(ptr p)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(psize);
|
1988-06-22 16:57:09 +00:00
|
|
|
st_stdp(SP, p);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push a word size integer "l" unto the stack. */
|
|
|
|
void wpush(long l)
|
1989-11-13 15:36:12 +00:00
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(wsize);
|
|
|
|
st_stw(SP, l);
|
1989-11-13 15:36:12 +00:00
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push "n" bytes from value "l" unto the stack. */
|
|
|
|
void npush(register long l, register size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
2019-03-17 14:42:00 +00:00
|
|
|
if (n <= wsize)
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(wsize);
|
2019-03-17 14:42:00 +00:00
|
|
|
if (n == 1)
|
|
|
|
l &= MASK1;
|
|
|
|
else if (n == 2)
|
|
|
|
l &= MASK2;
|
1989-11-22 13:38:37 +00:00
|
|
|
st_stw(SP, l);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
else
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(n);
|
|
|
|
st_stn(SP, l, n);
|
|
|
|
}
|
1988-06-22 16:57:09 +00:00
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push "n" bytes of data pointed to by the
|
|
|
|
* data pointer "d" unto the stack.
|
|
|
|
*/
|
|
|
|
void push_dt(ptr d, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
2019-03-17 14:42:00 +00:00
|
|
|
if (n < wsize)
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
npush((long) dt_ldu(d, n), n);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
else
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(n);
|
1988-06-22 16:57:09 +00:00
|
|
|
st_mvd(SP, d, n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push word size bytes of data pointed to by
|
|
|
|
* the data pointer "d" unto the stack.
|
|
|
|
*/
|
|
|
|
void pushw_dt(ptr d)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
incSP(wsize);
|
|
|
|
st_mvd(SP, d, wsize);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push "n" bytes of data pointed to by the
|
|
|
|
* stack pointer "s" unto the stack.
|
|
|
|
*/
|
|
|
|
void push_st(ptr s, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
2019-03-17 14:42:00 +00:00
|
|
|
if (n < wsize)
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
npush((long) st_ldu(s, n), n);
|
|
|
|
}
|
2019-03-17 14:42:00 +00:00
|
|
|
else
|
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(n);
|
1988-06-22 16:57:09 +00:00
|
|
|
st_mvs(SP, s, n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push word size bytes of data pointed to by
|
|
|
|
* the stack pointer "s" unto the stack.
|
|
|
|
*/
|
|
|
|
void pushw_st(ptr s)
|
1989-11-22 13:38:37 +00:00
|
|
|
{
|
|
|
|
incSP(wsize);
|
|
|
|
st_mvs(SP, s, wsize);
|
|
|
|
}
|
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifndef NOFLOAT
|
2019-03-17 14:42:00 +00:00
|
|
|
/** Push a real value of "n" bytes unto the stack. */
|
|
|
|
void fpush(double f, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP(n);
|
1988-06-22 16:57:09 +00:00
|
|
|
st_stf(SP, f, n);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* NOFLOAT */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#ifdef LOGGING
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
PRIVATE void warn_stbits(ptr addr, size n)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
register int or_bits = 0;
|
|
|
|
register int and_bits = 0xff;
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
while (n--)
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
or_bits |= st_sh(addr);
|
|
|
|
and_bits &= st_sh(addr);
|
|
|
|
addr++;
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
if (or_bits != and_bits)
|
|
|
|
{
|
1988-06-22 16:57:09 +00:00
|
|
|
/* no use trying to diagnose */
|
|
|
|
warningcont(WWASMISC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (or_bits == 0)
|
|
|
|
warningcont(WWASUND);
|
|
|
|
if (or_bits & SH_INT)
|
|
|
|
warningcont(WWASINT);
|
|
|
|
if (or_bits & SH_FLOAT)
|
|
|
|
warningcont(WWASFLOAT);
|
|
|
|
if (or_bits & SH_DATAP)
|
|
|
|
warningcont(WWASDATAP);
|
|
|
|
if (or_bits & SH_INSP)
|
|
|
|
warningcont(WWASINSP);
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
PRIVATE void st_clear_area(ptr from, ptr to)
|
|
|
|
{
|
|
|
|
/* includes both *from and *to (since ML+1 is unexpressible) */
|
|
|
|
register ptr a;
|
|
|
|
|
|
|
|
for (a = from; a >= to; a--) {
|
|
|
|
st_undef(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|