ack/util/int/do_incdec.c

456 lines
7.2 KiB
C
Raw Normal View History

1988-06-22 16:57:09 +00:00
/*
* Sources of the "INCREMENT/DECREMENT/ZERO" group instructions
*/
/* $Header$ */
#include <em_abs.h>
#include "global.h"
#include "log.h"
#include "nofloat.h"
#include "trap.h"
#include "mem.h"
#include "text.h"
#include "fra.h"
#include "warn.h"
PRIVATE long inc(), dec();
DoINCz()
{
/* INC -: Increment word on top of stack by 1 (*) */
LOG(("@Z6 DoINCz()"));
spoilFRA();
1989-11-22 13:38:37 +00:00
wpush(inc(swpop()));
1988-06-22 16:57:09 +00:00
}
DoINLm(arg)
long arg;
{
/* INL l: Increment local or parameter (*) */
register long l = arg_l(arg);
register ptr p;
LOG(("@Z6 DoINLm(%ld)", l));
spoilFRA();
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINLn2(arg)
long arg;
{
/* INL l: Increment local or parameter (*) */
register long l = (N_arg_2() * arg);
register ptr p;
LOG(("@Z6 DoINLn2(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINLn4(arg)
long arg;
{
/* INL l: Increment local or parameter (*) */
register long l = (N_arg_4() * arg);
register ptr p;
LOG(("@Z6 DoINLn4(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINLp2(arg)
long arg;
{
/* INL l: Increment local or parameter (*) */
register long l = (P_arg_2() * arg);
register ptr p;
LOG(("@Z6 DoINLp2(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINLp4(arg)
long arg;
{
/* INL l: Increment local or parameter (*) */
register long l = (P_arg_4() * arg);
register ptr p;
LOG(("@Z6 DoINLp4(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINLs(hob, wfac)
long hob;
size wfac;
{
/* INL l: Increment local or parameter (*) */
register long l = (S_arg(hob) * wfac);
register ptr p;
LOG(("@Z6 DoINLs(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINEl2(arg)
long arg;
{
/* INE g: Increment external (*) */
register ptr p = i2p(L_arg_2() * arg);
LOG(("@Z6 DoINEl2(%lu)", p));
spoilFRA();
p = arg_g(p);
1989-11-22 13:38:37 +00:00
dt_stw(p, inc(dt_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINEl4(arg)
long arg;
{
/* INE g: Increment external (*) */
register ptr p = i2p(L_arg_4() * arg);
LOG(("@Z6 DoINEl4(%lu)", p));
spoilFRA();
p = arg_g(p);
1989-11-22 13:38:37 +00:00
dt_stw(p, inc(dt_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoINEs(hob, wfac)
long hob;
size wfac;
{
/* INE g: Increment external (*) */
register ptr p = i2p(S_arg(hob) * wfac);
LOG(("@Z6 DoINEs(%lu)", p));
spoilFRA();
p = arg_g(p);
1989-11-22 13:38:37 +00:00
dt_stw(p, inc(dt_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDECz()
{
/* DEC -: Decrement word on top of stack by 1 (*) */
LOG(("@Z6 DoDECz()"));
spoilFRA();
1989-11-22 13:38:37 +00:00
wpush(dec(swpop()));
1988-06-22 16:57:09 +00:00
}
DoDELn2(arg)
long arg;
{
/* DEL l: Decrement local or parameter (*) */
register long l = (N_arg_2() * arg);
register ptr p;
LOG(("@Z6 DoDELn2(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, dec(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDELn4(arg)
long arg;
{
/* DEL l: Decrement local or parameter (*) */
register long l = (N_arg_4() * arg);
register ptr p;
LOG(("@Z6 DoDELn4(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, dec(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDELp2(arg)
long arg;
{
/* DEL l: Decrement local or parameter (*) */
register long l = (P_arg_2() * arg);
register ptr p;
LOG(("@Z6 DoDELp2(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, dec(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDELp4(arg)
long arg;
{
/* DEL l: Decrement local or parameter (*) */
register long l = (P_arg_4() * arg);
register ptr p;
LOG(("@Z6 DoDELp4(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, dec(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDELs(hob, wfac)
long hob;
size wfac;
{
/* DEL l: Decrement local or parameter (*) */
register long l = (S_arg(hob) * wfac);
register ptr p;
LOG(("@Z6 DoDELs(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
1989-11-22 13:38:37 +00:00
st_stw(p, dec(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDEEl2(arg)
long arg;
{
/* DEE g: Decrement external (*) */
register ptr p = i2p(L_arg_2() * arg);
LOG(("@Z6 DoDEEl2(%lu)", p));
spoilFRA();
p = arg_g(p);
1989-11-22 13:38:37 +00:00
dt_stw(p, dec(dt_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDEEl4(arg)
long arg;
{
/* DEE g: Decrement external (*) */
register ptr p = i2p(L_arg_4() * arg);
LOG(("@Z6 DoDEEl4(%lu)", p));
spoilFRA();
p = arg_g(p);
1989-11-22 13:38:37 +00:00
dt_stw(p, dec(dt_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoDEEs(hob, wfac)
long hob;
size wfac;
{
/* DEE g: Decrement external (*) */
register ptr p = i2p(S_arg(hob) * wfac);
LOG(("@Z6 DoDEEs(%lu)", p));
spoilFRA();
p = arg_g(p);
1989-11-22 13:38:37 +00:00
dt_stw(p, dec(dt_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
DoZRLm(arg)
long arg;
{
/* ZRL l: Zero local or parameter */
register long l = arg_l(arg);
LOG(("@Z6 DoZRLm(%ld)", l));
spoilFRA();
1989-11-22 13:38:37 +00:00
st_stw(loc_addr(l), 0L);
1988-06-22 16:57:09 +00:00
}
DoZRLn2(arg)
long arg;
{
/* ZRL l: Zero local or parameter */
register long l = (N_arg_2() * arg);
LOG(("@Z6 DoZRLn2(%ld)", l));
spoilFRA();
l = arg_l(arg);
1989-11-22 13:38:37 +00:00
st_stw(loc_addr(l), 0L);
1988-06-22 16:57:09 +00:00
}
DoZRLn4(arg)
long arg;
{
/* ZRL l: Zero local or parameter */
register long l = (N_arg_4() * arg);
LOG(("@Z6 DoZRLn4(%ld)", l));
spoilFRA();
l = arg_l(l);
1989-11-22 13:38:37 +00:00
st_stw(loc_addr(l), 0L);
1988-06-22 16:57:09 +00:00
}
DoZRLp2(arg)
long arg;
{
/* ZRL l: Zero local or parameter */
register long l = (P_arg_2() * arg);
LOG(("@Z6 DoZRLp2(%ld)", l));
spoilFRA();
l = arg_l(l);
1989-11-22 13:38:37 +00:00
st_stw(loc_addr(l), 0L);
1988-06-22 16:57:09 +00:00
}
DoZRLp4(arg)
long arg;
{
/* ZRL l: Zero local or parameter */
register long l = (P_arg_4() * arg);
LOG(("@Z6 DoZRLp4(%ld)", l));
spoilFRA();
l = arg_l(l);
1989-11-22 13:38:37 +00:00
st_stw(loc_addr(l), 0L);
1988-06-22 16:57:09 +00:00
}
DoZRLs(hob, wfac)
long hob;
size wfac;
{
/* ZRL l: Zero local or parameter */
register long l = (S_arg(hob) * wfac);
LOG(("@Z6 DoZRLs(%ld)", l));
spoilFRA();
l = arg_l(l);
1989-11-22 13:38:37 +00:00
st_stw(loc_addr(l), 0L);
1988-06-22 16:57:09 +00:00
}
DoZREl2(arg)
long arg;
{
/* ZRE g: Zero external */
register ptr p = i2p(L_arg_2() * arg);
LOG(("@Z6 DoZREl2(%lu)", p));
spoilFRA();
1989-11-22 13:38:37 +00:00
dt_stw(arg_g(p), 0L);
1988-06-22 16:57:09 +00:00
}
DoZREl4(arg)
long arg;
{
/* ZRE g: Zero external */
register ptr p = i2p(L_arg_4() * arg);
LOG(("@Z6 DoZREl4(%lu)", p));
spoilFRA();
1989-11-22 13:38:37 +00:00
dt_stw(arg_g(p), 0L);
1988-06-22 16:57:09 +00:00
}
DoZREs(hob, wfac)
long hob;
size wfac;
{
/* ZRE g: Zero external */
register ptr p = i2p(S_arg(hob) * wfac);
LOG(("@Z6 DoZREs(%lu)", p));
spoilFRA();
1989-11-22 13:38:37 +00:00
dt_stw(arg_g(p), 0L);
1988-06-22 16:57:09 +00:00
}
DoZRFl2(arg)
size arg;
{
/* ZRF w: Load a floating zero of size w */
#ifndef NOFLOAT
register size l = (L_arg_2() * arg);
LOG(("@Z6 DoZRFl2(%ld)", l));
spoilFRA();
fpush(0.0, arg_wf(l));
#else NOFLOAT
arg = arg;
nofloat();
#endif NOFLOAT
}
DoZRFz()
{
/* ZRF w: Load a floating zero of size w */
#ifndef NOFLOAT
1989-11-22 13:38:37 +00:00
register size l = uwpop();
1988-06-22 16:57:09 +00:00
LOG(("@Z6 DoZRFz(%ld)", l));
spoilFRA();
fpush(0.0, arg_wf(l));
#else NOFLOAT
nofloat();
#endif NOFLOAT
}
DoZERl2(arg)
size arg;
{
/* ZER w: Load w zero bytes */
register size i, l = (L_arg_2() * arg);
LOG(("@Z6 DoZERl2(%ld)", l));
spoilFRA();
for (i = arg_w(l); i; i -= wsize)
wpush(0L);
1988-06-22 16:57:09 +00:00
}
DoZERs(hob, wfac)
long hob;
size wfac;
{
/* ZER w: Load w zero bytes */
register size i, l = (S_arg(hob) * wfac);
LOG(("@Z6 DoZERs(%ld)", l));
spoilFRA();
for (i = arg_w(l); i; i -= wsize)
wpush(0L);
1988-06-22 16:57:09 +00:00
}
DoZERz()
{
/* ZER w: Load w zero bytes */
1989-11-22 13:38:37 +00:00
register size i, l = swpop();
1988-06-22 16:57:09 +00:00
LOG(("@Z6 DoZERz(%ld)", l));
spoilFRA();
for (i = arg_w(l); i; i -= wsize)
wpush(0L);
1988-06-22 16:57:09 +00:00
}
PRIVATE long inc(l)
long l;
{
if (must_test && !(IgnMask&BIT(EIOVFL))) {
if (l == i_maxsw)
trap(EIOVFL);
}
return (l + 1);
}
PRIVATE long dec(l)
long l;
{
if (must_test && !(IgnMask&BIT(EIOVFL))) {
if (l == i_minsw)
trap(EIOVFL);
}
return (l - 1);
}