ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
26 апреля
851567 Топик полностью
m16_home (28.06.2018 13:13, просмотров: 310) ответил mse homjak на В своё время Мбеддер выкладывал программку ИТОА для ДСПИК. Смешное кол-во тактов. И ни одного деления, что характерно. Реализуется на чём попало. А получив ASCII, вопрос анализа сводится к знамо дело, чему.
вот ;------------------------------------------------------------------------------------------------------ ; Converts an unsigned integer N in w0 to a 5-byte ASCII numerical string [w4] ; using a reciprocal multiplication and fractional conversion techniques. ; 21 clocks including RETURN, 13 program words. ; Registers trashed: w0..w3 (save/restore if needed). ; Register modified: w4 (points to the next free ASCII buffer byte position after execution). ; inv10k = 429497 ; =~ 2^32/10000 uitoa: mov #inv10k >> 16,w1 ; w1 = inv10k MSW mul.uu w1,w0,w2 ; w3w2 = partial product MSWs mov #inv10k & 0xFFFF,w1 ; w1 = inv10k LSW mul.uu w1,w0,w0 ; w1w0 = partial product LSWs add w1,w2,w0 ; w0 = fract(N%10000) mov #'0',w2 ; w2 = ASCII bit mask addc.b w3,w2,[w4++] ; w3 = N/10000, store an ASCII MS digit inc w0,w0 ; Correct the remainder to use 16-bit ops do #3,1f ; Repeat a next code block 4 times mul.uu w0,#10,w0 ; w1 = next ASCII digit (0..9 range), w0 = fractional remainder 1: ior.b w1,w2,[w4++] ; Convert to ASCII and store a next digit return ;------------------------------------------------------------------------------------------------------