1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-06-10 17:29:34 +00:00

Use tuples to store conversion data

This commit is contained in:
Mike Naberezny 2014-08-24 14:42:20 -07:00
parent 4c15430e02
commit 11ef8d4de4

View File

@ -18,14 +18,14 @@ def itoa(num, base=10):
def convert_to_bin(bcd):
return bcd2bin[bcd]
return _bcd2bin[bcd]
def convert_to_bcd(bin):
return bin2bcd[bin]
return _bin2bcd[bin]
bcd2bin = [
_bcd2bin = (
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 30, 31, 32, 33, 34, 35, 36, 37,
@ -42,10 +42,10 @@ bcd2bin = [
140, 141, 142, 143, 144, 145, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 150, 151, 152, 153, 154, 155,
156, 157, 158, 159, 160, 161, 162, 163, 164, 165
]
)
bin2bcd = [
_bin2bcd = (
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
@ -56,4 +56,4 @@ bin2bcd = [
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99
]
)