2016-03-20 18:16:19 +01:00
|
|
|
#ifndef QEMU_BCD_H
|
2016-06-29 15:29:06 +02:00
|
|
|
#define QEMU_BCD_H
|
2016-03-20 18:16:19 +01:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|