Here is another one solution, you need two truth tables, know how to get a nibble (4 digits that they aka a Hexadecimal number) and a adder...
The first table will have at max two BCD digits:
Code:
table A
0000 | 0000 0000
0001 | 0000 0001
·
·
1001 | 0000 1001
============= -> from this part the translation isnt direct ;)
1010 | 0001 0000
1011 | 0001 0001
·
·
1110 | 0001 0100
1111 | 0001 0101
The second table is the next power of 16... a number like FF is 15*16+ 15*1 = 255 and with this second table you can translatte more than 8 bit binar numbers, because you can always directly know the next power...
The thing is that it will have at max 3 digits (240 = 15*16)
Code:
table B
0000 | 0000 0000 0000 = 0
0001 | 0000 0001 0110 = 16
0010 | 0000 0011 0010 = 32
·
·
·
1111 | 0010 0100 0000 = 240
By the way, you know that from 10 the high order will have a 1, yu can optmize it a little pheraphs????? that is if there is a 1, the others dosent matter
... play with this tables and pheraphs some thing can be minimized more.....
Also now that you know, you can merge in memory both tables....
Code:
Mix a and b
0000 | 0000 0000 || 0000 0000 0000
0001 | 0000 0001 || 0000 0001 0110
·
·
1001 | 0000 1001 || 16* 9 (in BCD sure)
1010 | 0001 0000 || 0001 0110 000 = 16*10 = 160
1011 | 0001 0001 || 16*11
·
·
1110 | 0001 0100 || 16*14
1111 | 0001 0101 || 0010 0100 0000
In that way you will have a 5*4b = 20 bytes per line and there are 16 = 16*20 = 320 bytes instead of the other table about 12 bytes per line and 256 entryes... 12*256 = 3972 bytes......
Then you can extract the nibles, access the table the first part for the unity and the second for the second nible (the high order) andd you ad them...
1111 1111 = 0010 0100 000 + 0001 0101 = 0010 0101 0101 = 255
Dont know if that will require more work, also havent played for know if I can conert with this method some about 32 bytes in binary number to BCD, but I guess should be easy...