starting bcd conversion

This commit is contained in:
2025-04-04 16:04:45 -07:00
parent 25ae52259d
commit 101f0b998f
2 changed files with 24 additions and 2 deletions

View File

@@ -2,6 +2,26 @@
User Extensions
*/
// Utility functions
uint8_t
dec_to_bcd(uint8_t n)
{
uint8_t bcd = 0;
uint8_t tens = n / 10;
bcd = tens << 4;
tens *= 10;
bcd += (n - tens) & 0x0f;
return bcd;
}
uint8_t
bcd_to_dec(uint8_t n)
{
return ((n>>4) * 10) + (n&0x0f);
}
// Definitions
object *
fn_now(object *args, object *env)