avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Printing octal (brain dump)


From: George Spelvin
Subject: Re: [avr-libc-dev] Printing octal (brain dump)
Date: 20 Dec 2016 01:39:27 -0500

I implemented the idea I had, of using mem_itoa with base 100
and then printing two digits.

Omitting the strrev code to make everything equal, mem_toa is 64 bytes,
and the modified decimal-only version I call mem_tod is 80 bytes.
u64toa_nibbles is 90 bytes.

(That's assuming a ret of the reversed string or a 2-byte rjmp to
strrev; add 2 bytes if using JMP.)

Here's the timing:

        Decimal                         Hex
Input   mem_toa mem_tod itoa    nibbles mem_toa itoa
 8 bit   269     220     217     141     194      98
16 bit   664     462     451     321     527     187
24 bit  1294     783     838     608    1008     276
32 bit  2059    1219    1167     948    1637     365
40 bit  3059    1775    1649    1395    2414     454
48 bit  4194    2373    2127    1895    3339     543
56 bit  5477    3069    2733    2459    4412     632
64 bit  6995    3822    3420    3130    5633     721

mem_tod has the advantage that it does no multiplies, so it works fine
on all devices.  The nibbles code is the fastest, and I haven't tried
to improve it yet.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]