[an error occurred while processing this directive] [an error occurred while processing this directive]
ранее в конфе всплывал такой алгоритм ...
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено d!ma_bo 29 мая 2002 г. 11:21
В ответ на: Ответ: Смотри отправлено Bill 29 мая 2002 г. 11:04

 
;A simple algorithm to convert binary to BCD is:
;1. Add 3 to every BCD nibble that's >=5
;2. Shift left
;Repeat until binary portion is all 0000

;Example: Convert $F9 to BCD

;0000 0000 0000 : 1111 1001
;0000 0000 0001 : 1111 0010 (shift left)
;0000 0000 0011 : 1110 0100 (shift left)
;0000 0000 0111 : 1100 1000 (shift left)
;0000 0000 1010 : 1100 1000 (add 3)
;0000 0001 0101 : 1001 0000 (shift left)
;0000 0001 1000 : 1001 0000 (add 3)
;0000 0011 0001 : 0010 0000 (shift left)
;0000 0110 0010 : 0100 0000 (shift left)
;0000 1001 0010 : 0100 0000 (add 3)
;0001 0010 0100 : 1000 0000 (shift left)
;0010 0100 1001 : 0000 0000 (shift left)

;And the left now holds BCD 249.
;MUCH easier than messing with IDIV and FDIV!!!
Успехов!



Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru