home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
pctchnqs
/
1991
/
number6
/
intmanip.h
< prev
next >
Wrap
Text File
|
1991-11-04
|
1KB
|
40 lines
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;
#if defined(__cplusplus)
// Address low byte of a word.
inline byte &lowb(word &x) {
return (*(byte *)&x);
}
// Address high byte of a word.
inline byte &hib(word &x) {
return (*((byte *)&x + 1));
}
// Address low byte of a dword.
inline byte &lowb(dword &x) {
return (*(byte *)&x);
}
// Address high byte of a dword.
inline byte &hib(dword &x) {
return (*((byte *)&x + 3));
}
// Address low word of a dword.
inline word &loww(dword &x) {
return (*(word *)&x);
}
// Address high word of a dword.
inline word &hiw(dword &x) {
return (*((word *)&x + 1));
}
#else
/* Address low byte of a word or dword. */
#define lowb(x) (*(byte *)&x)
/* Address high byte of a word or dword. */
#define hib(x) (*((byte *)&x + sizeof(x) - 1))
/* Address low word of a dword. */
#define loww(x) (*(word *)&x)
/* Address high word of a dword. */
#define hiw(x) (*((word *)&x + 1))
#endif