ack/util/int/do_incdec.c

153 lines
2.3 KiB
C
Raw Normal View History

2019-03-17 14:42:00 +00:00
/** @file
* Sources of the "INCREMENT/DECREMENT/ZERO" group instructions
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
2019-03-17 14:42:00 +00:00
#include "em_abs.h"
1988-06-22 16:57:09 +00:00
#include "global.h"
#include "log.h"
#include "nofloat.h"
#include "trap.h"
#include "mem.h"
2019-03-17 14:42:00 +00:00
#include "data.h"
1988-06-22 16:57:09 +00:00
#include "text.h"
2019-03-17 14:42:00 +00:00
#include "stack.h"
1988-06-22 16:57:09 +00:00
#include "fra.h"
#include "warn.h"
#include "switch.h"
1988-06-22 16:57:09 +00:00
2019-03-17 14:42:00 +00:00
PRIVATE long inc(long), dec(long);
1988-06-22 16:57:09 +00:00
2019-03-17 14:42:00 +00:00
/** INC -: Increment word on top of stack by 1 (*) */
void DoINC(void)
1988-06-22 16:57:09 +00:00
{
LOG(("@Z6 DoINC()"));
1988-06-22 16:57:09 +00:00
spoilFRA();
1989-11-22 13:38:37 +00:00
wpush(inc(swpop()));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** INL l: Increment local or parameter (*) */
void DoINL(register long l)
1988-06-22 16:57:09 +00:00
{
register ptr p;
LOG(("@Z6 DoINL(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
p = loc_addr(arg_l(l));
1989-11-22 13:38:37 +00:00
st_stw(p, inc(st_ldsw(p)));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** INE g: Increment external (*) */
void DoINE(register long arg)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
register ptr p = i2p(arg);
1988-06-22 16:57:09 +00:00
LOG(("@Z6 DoINE(%lu)", p));
1988-06-22 16:57:09 +00:00
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
}
2019-03-17 14:42:00 +00:00
/** DEC -: Decrement word on top of stack by 1 (*) */
void DoDEC(void)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
LOG(("@Z6 DoDEC()"));
1988-06-22 16:57:09 +00:00
spoilFRA();
1989-11-22 13:38:37 +00:00
wpush(dec(swpop()));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** DEL l: Decrement local or parameter (*) */
void DoDEL(register long l)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
1988-06-22 16:57:09 +00:00
register ptr p;
LOG(("@Z6 DoDEL(%ld)", l));
1988-06-22 16:57:09 +00:00
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
}
2019-03-17 14:42:00 +00:00
/** DEE g: Decrement external (*) */
void DoDEE(register long arg)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
register ptr p = i2p(arg);
1988-06-22 16:57:09 +00:00
LOG(("@Z6 DoDEE(%lu)", p));
1988-06-22 16:57:09 +00:00
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
}
2019-03-17 14:42:00 +00:00
/** ZRL l: Zero local or parameter */
void DoZRL(register long l)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
1988-06-22 16:57:09 +00:00
LOG(("@Z6 DoZRL(%ld)", l));
1988-06-22 16:57:09 +00:00
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
}
2019-03-17 14:42:00 +00:00
/** ZRE g: Zero external */
void DoZRE(register long arg)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
register ptr p = i2p(arg);
1988-06-22 16:57:09 +00:00
LOG(("@Z6 DoZRE(%lu)", p));
1988-06-22 16:57:09 +00:00
spoilFRA();
1989-11-22 13:38:37 +00:00
dt_stw(arg_g(p), 0L);
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** ZRF w: Load a floating zero of size w */
void DoZRF(register size l)
1988-06-22 16:57:09 +00:00
{
2019-03-17 14:42:00 +00:00
1988-06-22 16:57:09 +00:00
#ifndef NOFLOAT
LOG(("@Z6 DoZRF(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
fpush(0.0, arg_wf(l));
#else /* NOFLOAT */
1988-06-22 16:57:09 +00:00
arg = arg;
nofloat();
#endif /* NOFLOAT */
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** ZER w: Load w zero bytes */
void DoZER(register size l)
1988-06-22 16:57:09 +00:00
{
LOG(("@Z6 DoZER(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
npush(0L, arg_w(l));
1988-06-22 16:57:09 +00:00
/*
1988-06-22 16:57:09 +00:00
for (i = arg_w(l); i; i -= wsize)
wpush(0L);
*/
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
PRIVATE long inc(long l)
1988-06-22 16:57:09 +00:00
{
if (must_test && !(IgnMask&BIT(EIOVFL))) {
if (l == i_maxsw)
trap(EIOVFL);
}
return (l + 1);
}
2019-03-17 14:42:00 +00:00
PRIVATE long dec(long l)
1988-06-22 16:57:09 +00:00
{
if (must_test && !(IgnMask&BIT(EIOVFL))) {
if (l == i_minsw)
trap(EIOVFL);
}
return (l - 1);
}