Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algorithm 1 - BCD to Binary (Integer)
- For every interation:
- Shift right
- If any BCD reg >= 8, subtract 3
- Example:
- 0100 0011 (43 in BCD) -> 00101011 (42 in Binary)
- 0100 0011 |
- 0010 0001 | 1
- 0001 0000 | 11
- 0000 1000 | 011 (x>=8, sub3)
- 0000 0101 | 011
- 0000 0010 | 1011
- 0000 0001 | 01011
- 0000 0000 | 101011
- 0000 0000 | 0101011
- 0000 0000 | 00101011
- Algorithm 2 - BCD to Binary (Fraction)
- For every interation:
- If any BCD reg >= 5, add 3
- Shift left
- Example:
- 0.0111 0101 (0.75 in BCD) -> 0.11000000 (0.75 in Binary)
- 0.00000000 | 0111 0101 (x>=5, add3)
- 0.00000000 | 1010 1000
- 0.00000001 | 0101 0000 (x>=5, add3)
- 0.00000001 | 1000 0000
- 0.00000011 | 0000 0000
- 0.00000110 | 0000 0000
- 0.00001100 | 0000 0000
- 0.00011000 | 0000 0000
- 0.00110000 | 0000 0000
- 0.01100000 | 0000 0000
- 0.11000000 | 0000 0000
- Algorithm 3 - Binary to BCD (Integer)
- For every interation:
- If any BCD reg >= 5, add 3
- Shift left
- Example:
- 00011001 (25 in Binary) -> 0010 0101 (25 in BCD)
- 0000 0000 | 00011001
- 0000 0000 | 0011001
- 0000 0000 | 011001
- 0000 0000 | 11001
- 0000 0001 | 1001
- 0000 0011 | 001
- 0000 0110 | 01 (x>=5, add3)
- 0000 1001 | 01
- 0001 0010 | 1
- 0010 0101 |
- Algorithm 4 - Binary to BCD (Fraction)
- For every interation:
- Shift right
- If any BCD reg >= 8, subtract 3
- Example:
- .0101 (.375 in Binary) -> .0011 0111 0101 (.375 in BCD)
- 0101 | 0000 0000 0000
- 0010 | 1000 0000 0000 (x>=8, sub3)
- 0010 | 0101 0000 0000
- 0001 | 1010 1000 0000 (x>=8, sub3)
- 0001 | 0111 0101 0000
- 0000 | 0011 1010 1000 (x>=8, sub3)
- 0000 | 0011 0111 0101
Advertisement
Add Comment
Please, Sign In to add comment