1988-02-19 15:54:01 +00:00
|
|
|
/*
|
|
|
|
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Module: get value on stack, byte by byte
|
|
|
|
Author: Ceriel J.H. Jacobs
|
1994-06-24 14:02:31 +00:00
|
|
|
Version: $Id$
|
1988-02-19 15:54:01 +00:00
|
|
|
*/
|
1988-03-18 14:23:04 +00:00
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
#include "libm2.h"
|
1988-03-18 14:23:04 +00:00
|
|
|
#include <m2_traps.h>
|
|
|
|
|
1990-11-02 14:29:02 +00:00
|
|
|
#ifndef EM_WSIZE
|
|
|
|
#define EM_WSIZE _EM_WSIZE
|
|
|
|
#define EM_PSIZE _EM_PSIZE
|
|
|
|
#endif
|
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
void load(size_t siz, char* addr, int p)
|
1987-05-13 14:36:45 +00:00
|
|
|
{
|
1988-03-18 14:23:04 +00:00
|
|
|
/* Make sure, that a value with a size that could have been
|
2018-06-25 20:22:37 +00:00
|
|
|
handled by the LOI instruction ends up at the same place,
|
|
|
|
where it would, were the LOI instruction used.
|
1988-03-18 14:23:04 +00:00
|
|
|
*/
|
2018-06-25 20:22:37 +00:00
|
|
|
register char* q = (char*)&p;
|
1988-03-18 14:23:04 +00:00
|
|
|
char t[4];
|
1987-05-13 14:36:45 +00:00
|
|
|
|
2018-06-25 20:22:37 +00:00
|
|
|
if (siz < EM_WSIZE && EM_WSIZE % siz == 0)
|
|
|
|
{
|
1988-03-18 14:23:04 +00:00
|
|
|
/* as long as EM_WSIZE <= 4 ... */
|
2018-06-25 20:22:37 +00:00
|
|
|
if (siz != 2)
|
|
|
|
TRP(M2_INTERNAL); /* internal error */
|
1988-03-18 14:23:04 +00:00
|
|
|
q = &t[0];
|
|
|
|
}
|
2018-06-25 20:22:37 +00:00
|
|
|
while (siz--)
|
|
|
|
*q++ = *addr++;
|
|
|
|
if (q - t == 2)
|
|
|
|
{
|
|
|
|
*((unsigned*)(&p)) = *((unsigned short*)(&t[0]));
|
1988-03-18 14:23:04 +00:00
|
|
|
}
|
1987-05-13 14:36:45 +00:00
|
|
|
}
|