]>
Commit | Line | Data |
---|---|---|
d6fe5ca5 MM |
1 | #ifndef ENDIAN_INLINE |
2 | #define NO_ENDIAN_INLINE | |
3 | #include "d10v_sim.h" | |
4 | #define ENDIAN_INLINE | |
5 | #endif | |
6 | ||
7 | ENDIAN_INLINE uint32 | |
8 | get_longword (x) | |
9 | uint8 *x; | |
10 | { | |
11 | return ((uint32)x[0]<<24) + ((uint32)x[1]<<16) + ((uint32)x[2]<<8) + ((uint32)x[3]); | |
12 | } | |
13 | ||
14 | ENDIAN_INLINE int64 | |
15 | get_longlong (x) | |
16 | uint8 *x; | |
17 | { | |
18 | uint32 top = ((uint32)x[0]<<24) + ((uint32)x[1]<<16) + ((uint32)x[2]<<8) + ((uint32)x[3]); | |
19 | uint32 bottom = ((uint32)x[4]<<24) + ((uint32)x[5]<<16) + ((uint32)x[6]<<8) + ((uint32)x[7]); | |
20 | return (((int64)top)<<32) | (int64)bottom; | |
21 | } | |
22 | ||
23 | ENDIAN_INLINE uint16 | |
24 | get_word (x) | |
25 | uint8 *x; | |
26 | { | |
27 | return ((uint16)x[0]<<8) + x[1]; | |
28 | } | |
29 | ||
30 | ENDIAN_INLINE void | |
31 | write_word (addr, data) | |
32 | uint8 *addr; | |
33 | uint16 data; | |
34 | { | |
35 | addr[0] = (data >> 8) & 0xff; | |
36 | addr[1] = data & 0xff; | |
37 | } | |
38 | ||
39 | ENDIAN_INLINE void | |
40 | write_longword (addr, data) | |
41 | uint8 *addr; | |
42 | uint32 data; | |
43 | { | |
44 | addr[0] = (data >> 24) & 0xff; | |
45 | addr[1] = (data >> 16) & 0xff; | |
46 | addr[2] = (data >> 8) & 0xff; | |
47 | addr[3] = data & 0xff; | |
48 | } | |
49 | ||
50 | ENDIAN_INLINE void | |
51 | write_longlong (addr, data) | |
52 | uint8 *addr; | |
53 | int64 data; | |
54 | { | |
55 | addr[0] = data >> 56; | |
56 | addr[1] = (data >> 48) & 0xff; | |
57 | addr[2] = (data >> 40) & 0xff; | |
58 | addr[3] = (data >> 32) & 0xff; | |
59 | addr[4] = (data >> 24) & 0xff; | |
60 | addr[5] = (data >> 16) & 0xff; | |
61 | addr[6] = (data >> 8) & 0xff; | |
62 | addr[7] = data & 0xff; | |
63 | } |