Skip to content

Commit dfcdf62

Browse files
committed
Add BCD format utils
1 parent 5349a26 commit dfcdf62

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

qiling/hw/utils/bcd.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+
6+
7+
def byte2bcd(value):
8+
bcdhigh = 0
9+
while value >= 10:
10+
bcdhigh += 1
11+
value -= 10
12+
13+
return (bcdhigh << 4) | value
14+
15+
def bcd2byte(value):
16+
return ((value & 0xF0) >> 0x4) * 10 + (value & 0xf)

0 commit comments

Comments
 (0)