diff options
author | Paul Brook <paul@codesourcery.com> | 2009-11-20 00:03:47 +0000 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-11-22 21:27:40 +0000 |
commit | abd0c6bda0c89f36528e1a7efac99277607a5280 (patch) | |
tree | c9e5adc54b76a3e428c3222a5e48b2c1cd39764c /qemu-common.h | |
parent | a992fe3d0fc185112677286f7a02204d8245b61e (diff) |
BCD cleanup
Combine multiple BCD implementations.
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'qemu-common.h')
-rw-r--r-- | qemu-common.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/qemu-common.h b/qemu-common.h index b779cfe69d..b1e038bd00 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -248,6 +248,17 @@ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count); struct Monitor; typedef struct Monitor Monitor; +/* Convert a byte between binary and BCD. */ +static inline uint8_t to_bcd(uint8_t val) +{ + return ((val / 10) << 4) | (val % 10); +} + +static inline uint8_t from_bcd(uint8_t val) +{ + return ((val >> 4) * 10) + (val & 0x0f); +} + #include "module.h" #endif /* dyngen-exec.h hack */ |