Guest User

Untitled

a guest
Oct 6th, 2024
2,673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. Algorithm 1 - BCD to Binary (Integer)
  2.  
  3. For every interation:
  4. Shift right
  5. If any BCD reg >= 8, subtract 3
  6.  
  7. Example:
  8. 0100 0011 (43 in BCD) -> 00101011 (42 in Binary)
  9.  
  10. 0100 0011 |
  11. 0010 0001 | 1
  12. 0001 0000 | 11
  13. 0000 1000 | 011 (x>=8, sub3)
  14. 0000 0101 | 011
  15. 0000 0010 | 1011
  16. 0000 0001 | 01011
  17. 0000 0000 | 101011
  18. 0000 0000 | 0101011
  19. 0000 0000 | 00101011
  20.  
  21.  
  22. Algorithm 2 - BCD to Binary (Fraction)
  23.  
  24. For every interation:
  25. If any BCD reg >= 5, add 3
  26. Shift left
  27.  
  28. Example:
  29. 0.0111 0101 (0.75 in BCD) -> 0.11000000 (0.75 in Binary)
  30.  
  31. 0.00000000 | 0111 0101 (x>=5, add3)
  32. 0.00000000 | 1010 1000
  33. 0.00000001 | 0101 0000 (x>=5, add3)
  34. 0.00000001 | 1000 0000
  35. 0.00000011 | 0000 0000
  36. 0.00000110 | 0000 0000
  37. 0.00001100 | 0000 0000
  38. 0.00011000 | 0000 0000
  39. 0.00110000 | 0000 0000
  40. 0.01100000 | 0000 0000
  41. 0.11000000 | 0000 0000
  42.  
  43.  
  44. Algorithm 3 - Binary to BCD (Integer)
  45.  
  46. For every interation:
  47. If any BCD reg >= 5, add 3
  48. Shift left
  49.  
  50. Example:
  51. 00011001 (25 in Binary) -> 0010 0101 (25 in BCD)
  52.  
  53. 0000 0000 | 00011001
  54. 0000 0000 | 0011001
  55. 0000 0000 | 011001
  56. 0000 0000 | 11001
  57. 0000 0001 | 1001
  58. 0000 0011 | 001
  59. 0000 0110 | 01 (x>=5, add3)
  60. 0000 1001 | 01
  61. 0001 0010 | 1
  62. 0010 0101 |
  63.  
  64.  
  65. Algorithm 4 - Binary to BCD (Fraction)
  66.  
  67. For every interation:
  68. Shift right
  69. If any BCD reg >= 8, subtract 3
  70.  
  71. Example:
  72. .0101 (.375 in Binary) -> .0011 0111 0101 (.375 in BCD)
  73.  
  74. 0101 | 0000 0000 0000
  75. 0010 | 1000 0000 0000 (x>=8, sub3)
  76. 0010 | 0101 0000 0000
  77. 0001 | 1010 1000 0000 (x>=8, sub3)
  78. 0001 | 0111 0101 0000
  79. 0000 | 0011 1010 1000 (x>=8, sub3)
  80. 0000 | 0011 0111 0101
Advertisement
Add Comment
Please, Sign In to add comment