ack/lang/m2/libm2/store.c

40 lines
876 B
C
Raw Permalink Normal View History

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: store values from 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
*/
#include "libm2.h"
#include <m2_traps.h>
#ifndef EM_WSIZE
#define EM_WSIZE _EM_WSIZE
#define EM_PSIZE _EM_PSIZE
#endif
void store(size_t siz, char* addr, int p)
1987-05-13 14:36:45 +00:00
{
/* Make sure, that a value with a size that could have been
handled by the LOI instruction is handled as if it was
loaded with the LOI instruction.
*/
register char* q = (char*)&p;
char t[4];
1987-05-13 14:36:45 +00:00
if (siz < EM_WSIZE && EM_WSIZE % siz == 0)
{
/* as long as EM_WSIZE <= 4 ... */
if (siz != 2)
TRP(M2_INTERNAL); /* internal error */
*((unsigned short*)(&t[0])) = *((unsigned*)q);
q = &t[0];
}
while (siz--)
*addr++ = *q++;
1987-05-13 14:36:45 +00:00
}