Rev | Line | |
---|
[9] | 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 | /*
|
---|
| 7 | Module: get value on stack, byte by byte
|
---|
| 8 | Author: Ceriel J.H. Jacobs
|
---|
| 9 | Version: $Header: /cvsup/minix/src/lib/ack/libm2/load.c,v 1.1 2005/10/10 15:27:46 beng Exp $
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | #include <m2_traps.h>
|
---|
| 13 |
|
---|
| 14 | #ifndef EM_WSIZE
|
---|
| 15 | #define EM_WSIZE _EM_WSIZE
|
---|
| 16 | #define EM_PSIZE _EM_PSIZE
|
---|
| 17 | #endif
|
---|
| 18 |
|
---|
| 19 | #if EM_WSIZE==EM_PSIZE
|
---|
| 20 | typedef unsigned pcnt;
|
---|
| 21 | #else
|
---|
| 22 | typedef long pcnt;
|
---|
| 23 | #endif
|
---|
| 24 |
|
---|
| 25 | load(siz, addr, p)
|
---|
| 26 | register char *addr;
|
---|
| 27 | register pcnt siz;
|
---|
| 28 | {
|
---|
| 29 | /* Make sure, that a value with a size that could have been
|
---|
| 30 | handled by the LOI instruction ends up at the same place,
|
---|
| 31 | where it would, were the LOI instruction used.
|
---|
| 32 | */
|
---|
| 33 | register char *q = (char *) &p;
|
---|
| 34 | char t[4];
|
---|
| 35 |
|
---|
| 36 | if (siz < EM_WSIZE && EM_WSIZE % siz == 0) {
|
---|
| 37 | /* as long as EM_WSIZE <= 4 ... */
|
---|
| 38 | if (siz != 2) TRP(M2_INTERNAL); /* internal error */
|
---|
| 39 | q = &t[0];
|
---|
| 40 | }
|
---|
| 41 | while (siz--) *q++ = *addr++;
|
---|
| 42 | if (q - t == 2) {
|
---|
| 43 | *((unsigned *)(&p)) = *((unsigned short *) (&t[0]));
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.