* Copyright (c) 1991,1990 Carnegie Mellon University
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
* Carnegie Mellon requests users of this software to return to
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
* Author: David B. Golub, Carnegie Mellon University
#include <machine/db_machdep.h> /* type definitions */
* Access unaligned data items on aligned (longword)
extern void db_read_bytes(); /* machine-dependent */
extern void db_write_bytes(); /* machine-dependent */
int db_extend
[] = { /* table for sign-extending */
db_get_value(addr
, size
, is_signed
)
register db_expr_t value
;
db_read_bytes(addr
, size
, data
);
for (i
= 0; i
< size
; i
++)
for (i
= size
- 1; i
>= 0; i
--)
value
= (value
<< 8) + (data
[i
] & 0xFF);
if (is_signed
&& (value
& db_extend
[size
]) != 0)
value
|= db_extend
[size
];
db_put_value(addr
, size
, value
)
register db_expr_t value
;
for (i
= size
- 1; i
>= 0; i
--)
for (i
= 0; i
< size
; i
++)
db_write_bytes(addr
, size
, data
);