1988-06-22 16:57:09 +00:00
|
|
|
/*
|
|
|
|
* Sources of the "POINTER ARITHMETIC" group instructions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Header$ */
|
|
|
|
|
|
|
|
#include <em_abs.h>
|
|
|
|
#include "segcheck.h"
|
|
|
|
#include "global.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "trap.h"
|
|
|
|
#include "warn.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "fra.h"
|
|
|
|
|
|
|
|
#define adp(p,w) ((p) + (w))
|
|
|
|
#define sbs(t,s) ((s) - (t))
|
|
|
|
|
|
|
|
#ifdef SEGCHECK
|
|
|
|
|
|
|
|
#define check_seg(s1,s2,w) if (s1 != s2) { warning(w); }
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define check_seg(s1,s2,w)
|
|
|
|
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* SEGCHECK */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoADP(l)
|
|
|
|
register long l;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ADP f: Add f to pointer on top of stack */
|
|
|
|
register ptr p, t = st_lddp(SP);
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@R6 DoADP(%ld)", l));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
if (t == 0) {
|
|
|
|
warning(WNULLPA);
|
|
|
|
}
|
|
|
|
l = arg_f(l);
|
|
|
|
p = adp(t, l);
|
|
|
|
check_seg(ptr2seg(t), ptr2seg(p), WSEGADP);
|
|
|
|
st_stdp(SP, p);
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoADS(l)
|
|
|
|
register size l;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* ADS w: Add w-byte value and pointer */
|
|
|
|
register long t = spop(arg_wi(l));
|
|
|
|
register ptr p, s = st_lddp(SP);
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@R6 DoADS(%ld)", l));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
t = arg_f(t);
|
|
|
|
if (s == 0) {
|
|
|
|
warning(WNULLPA);
|
|
|
|
}
|
|
|
|
p = adp(s, t);
|
|
|
|
check_seg(ptr2seg(s), ptr2seg(p), WSEGADP);
|
|
|
|
st_stdp(SP, p);
|
|
|
|
}
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
DoSBS(l)
|
|
|
|
register size l;
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* SBS w: Subtract pointers in same fragment and push diff as size w integer */
|
|
|
|
register ptr t = st_lddp(SP);
|
|
|
|
register ptr s = st_lddp(SP + psize);
|
|
|
|
register long w;
|
|
|
|
|
1990-06-21 12:16:31 +00:00
|
|
|
LOG(("@R6 DoSBS(%ld)", l));
|
1988-06-22 16:57:09 +00:00
|
|
|
spoilFRA();
|
|
|
|
l = arg_wi(l);
|
|
|
|
check_seg(ptr2seg(t), ptr2seg(s), WSEGSBS);
|
|
|
|
w = sbs(t, s);
|
|
|
|
if (must_test && !(IgnMask&BIT(EIOVFL))) {
|
|
|
|
if (l == 2 && (w < I_MINS2 || w > I_MAXS2))
|
|
|
|
trap(EIOVFL);
|
|
|
|
}
|
|
|
|
dppop();
|
|
|
|
dppop();
|
|
|
|
npush(w, l);
|
|
|
|
}
|