diff --git a/src/ucore_bcd.c b/src/ucore_bcd.c index 9a202d9..3dd978c 100644 --- a/src/ucore_bcd.c +++ b/src/ucore_bcd.c @@ -16,14 +16,14 @@ uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler) continue; } - *bcdp |= (*ascii - '0') << shift; - if (shift) { + *bcdp |= (*ascii - '0') << 4; bcdp++; - *bcdp = 0; + } else { + *bcdp = (*ascii - '0'); } - shift = 4 - shift; + shift = !shift; } if (shift) {