store.c 950 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /*
  6. Module: store values from stack, byte by byte
  7. Author: Ceriel J.H. Jacobs
  8. Version: $Id$
  9. */
  10. #include <m2_traps.h>
  11. #ifndef EM_WSIZE
  12. #define EM_WSIZE _EM_WSIZE
  13. #define EM_PSIZE _EM_PSIZE
  14. #endif
  15. #if EM_WSIZE==EM_PSIZE
  16. typedef unsigned pcnt;
  17. #else
  18. typedef long pcnt;
  19. #endif
  20. store(siz, addr, p)
  21. register char *addr;
  22. register pcnt siz;
  23. {
  24. /* Make sure, that a value with a size that could have been
  25. handled by the LOI instruction is handled as if it was
  26. loaded with the LOI instruction.
  27. */
  28. register char *q = (char *) &p;
  29. char t[4];
  30. if (siz < EM_WSIZE && EM_WSIZE % siz == 0) {
  31. /* as long as EM_WSIZE <= 4 ... */
  32. if (siz != 2) TRP(M2_INTERNAL); /* internal error */
  33. *((unsigned short *) (&t[0])) = *((unsigned *) q);
  34. q = &t[0];
  35. }
  36. while (siz--) *addr++ = *q++;
  37. }