ack/util/int/do_load.c

195 lines
3.4 KiB
C
Raw Permalink Normal View History

2019-03-17 14:42:00 +00:00
/** @file
* Sources of the "LOAD" 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 "mem.h"
#include "trap.h"
#include "text.h"
#include "fra.h"
#include "rsb.h"
#include "warn.h"
#include "switch.h"
1988-06-22 16:57:09 +00:00
2019-03-17 14:42:00 +00:00
PRIVATE ptr lexback_LB(unsigned long);
1988-06-22 16:57:09 +00:00
2019-03-17 14:42:00 +00:00
/** LOC c: Load constant (i.e. push one word onto the stack) */
void DoLOC(register long l)
1988-06-22 16:57:09 +00:00
{
LOG(("@L6 DoLOC(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
wpush(arg_c(l));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** LDC d: Load double constant ( push two words ) */
void DoLDC(register long l)
1988-06-22 16:57:09 +00:00
{
LOG(("@L6 DoLDC(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_d(l);
1988-06-22 16:57:09 +00:00
npush(l, dwsize);
}
2019-03-17 14:42:00 +00:00
/** LOL l: Load word at l-th local (l<0) or parameter (l>=0) */
void DoLOL(register long l)
1988-06-22 16:57:09 +00:00
{
LOG(("@L6 DoLOL(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_l(l);
1989-11-22 13:38:37 +00:00
pushw_st(loc_addr(l));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** LOE g: Load external word g */
void DoLOE(register long arg)
1988-06-22 16:57:09 +00:00
{
register ptr p = i2p(arg);
1988-06-22 16:57:09 +00:00
LOG(("@L6 DoLOE(%lu)", p));
1988-06-22 16:57:09 +00:00
spoilFRA();
1989-11-22 13:38:37 +00:00
pushw_m(arg_g(p));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** LIL l: Load word pointed to by l-th local or parameter */
void DoLIL(register long l)
1988-06-22 16:57:09 +00:00
{
LOG(("@L6 DoLIL(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_l(l);
1989-11-22 13:38:37 +00:00
pushw_m(st_lddp(loc_addr(l)));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** LOF f: Load offsetted (top of stack + f yield address) */
void DoLOF(register long l)
1988-06-22 16:57:09 +00:00
{
register ptr p = dppop();
LOG(("@L6 DoLOF(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
1989-11-22 13:38:37 +00:00
pushw_m(p + arg_f(l));
1988-06-22 16:57:09 +00:00
}
2019-03-17 14:42:00 +00:00
/** LAL l: Load address of local or parameter */
void DoLAL(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(("@L6 DoLAL(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_l(l);
dppush(loc_addr(l));
}
2019-03-17 14:42:00 +00:00
/** LAE g: Load address of external */
void DoLAE(register unsigned 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(("@L6 DoLAE(%lu)", p));
1988-06-22 16:57:09 +00:00
spoilFRA();
dppush(arg_lae(p));
}
2019-03-17 14:42:00 +00:00
/** LXL n: Load lexical (address of LB n static levels back) */
void DoLXL(register unsigned long l)
1988-06-22 16:57:09 +00:00
{
register ptr p;
LOG(("@L6 DoLXL(%lu)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_n(l);
p = lexback_LB(l);
dppush(p);
}
2019-03-17 14:42:00 +00:00
/** LXA n: Load lexical (address of AB n static levels back) */
void DoLXA(register unsigned long l)
1988-06-22 16:57:09 +00:00
{
register ptr p;
LOG(("@L6 DoLXA(%lu)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_n(l);
p = lexback_LB(l);
dppush(p + rsbsize);
}
2019-03-17 14:42:00 +00:00
/** LOI o: Load indirect o bytes (address is popped from the stack) */
void DoLOI(register size l)
1988-06-22 16:57:09 +00:00
{
register ptr p = dppop();
LOG(("@L6 DoLOI(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_o(l);
1988-06-22 16:57:09 +00:00
push_m(p, l);
}
2019-03-17 14:42:00 +00:00
/** LOS w: Load indirect, w-byte integer on top of stack gives
* object size */
void DoLOS(register size l)
1988-06-22 16:57:09 +00:00
{
register ptr p;
LOG(("@L6 DoLOS(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_wi(l);
l = upop(l);
p = dppop();
push_m(p, arg_o(l));
}
2019-03-17 14:42:00 +00:00
/** LDL l: Load double local or parameter (two consecutive words are stacked) */
void DoLDL(register long l)
1988-06-22 16:57:09 +00:00
{
LOG(("@L6 DoLDL(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
l = arg_l(l);
push_st(loc_addr(l), dwsize);
}
2019-03-17 14:42:00 +00:00
/** LDE g: Load double external (two consecutive externals are stacked) */
void DoLDE(register long arg)
1988-06-22 16:57:09 +00:00
{
register ptr p = i2p(arg);
1988-06-22 16:57:09 +00:00
LOG(("@L6 DoLDE(%lu)", p));
1988-06-22 16:57:09 +00:00
spoilFRA();
push_m(arg_g(p), dwsize);
}
2019-03-17 14:42:00 +00:00
/** LDF f: Load double offsetted (top of stack + f yield address) */
void DoLDF(register long l)
1988-06-22 16:57:09 +00:00
{
register ptr p = dppop();
LOG(("@L6 DoLDF(%ld)", l));
1988-06-22 16:57:09 +00:00
spoilFRA();
push_m(p + arg_f(l), dwsize);
}
2019-03-17 14:42:00 +00:00
/** LPI p: Load procedure identifier */
void DoLPI(register long pi)
1988-06-22 16:57:09 +00:00
{
LOG(("@L6 DoLPI(%ld)", pi));
1988-06-22 16:57:09 +00:00
spoilFRA();
npush(arg_p(pi), psize);
}
2019-03-17 14:42:00 +00:00
PRIVATE ptr lexback_LB(unsigned long n)
1988-06-22 16:57:09 +00:00
{
/* LB n static levels back */
register ptr lb = LB;
while (n != 0) {
lb = st_lddp(lb + rsbsize);
n--;
}
return lb;
}