[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Plans to update scanf().
From: |
Dmitry K. |
Subject: |
[avr-libc-dev] Plans to update scanf(). |
Date: |
Sun, 17 Feb 2008 16:40:36 +1000 |
User-agent: |
KMail/1.5 |
Hi.
In the near future I am going to update vfscanf() function
- a core of all scanf family (first only the HEAD branch).
========================================================================
Function vfscanf() is rewriten. The float point version is optimized
considerably: the expense of a stack was cut by half, and the size of
function has decreased approximately on 1KB. Opportunities of standard
and minimal versions are expanded, and their size has remained at a
former level.
Briefly:
. Restrictions of a float point format are eliminated.
. Conversion '%[' is present in standart version now.
. The minimal version differs from standard only absence of '%[' conversion.
. The 'hh' type qualifier is added ('char *', C99).
. The maximal field width is increased up to 255 (65535 in float version).
. All known bugs are fixed.
New vfscanf() concedes old in:
. The size of the minimal and standard versions has increased for old
branches of compiler and ancient chips (without MOVW).
. The maximum quantity of conversions now is limited (255).
More in detail:
. The old vfscanf() used the intermediate buffer for float point numbers.
The size of this buffer made 40 bytes. Though for practice it is too much,
all range has not been blocked (1.4e-45 ... 3.4e+38). In the new vfscanf()
decoding goes on the fly, and for the size of number there are no
restrictions. Also the new version understands abreviatury for NaN and Inf.
. The '%[' is realized as separate function, therefore a stack spent only
in case of real usage.
. Earlier the minimal version considerably differed from standard: there
was no comparison of symbols, there was no miss of storing, there was no
width of a field. Actually, it was absolutely other function. As a rule,
the program written counting upon standard scanf() could not be translated
without serious consequences on the minimal version.
. The size of the minimal and standard versions has increased for old
branches of compiler and ancient chips (without MOVW). For modern chips
and compilers of 4.1 - 4.3 branches, it is possible to tell, that the size
about the same. Besides now the minimal version covers all functions old
standard.
. Restriction of conversion quantity has arisen because of reduction of
the size of the counter up to one byte. It has allowed to reduce
considerably the size connected with shortage of registers. Let's notice,
that the call scanf() with 255 conversions will demand more than 0.5KB
a stack only on transfer of addresses.
. In the source the manual adjustment of parameters (the size of width of
a field, presence of '%[' and a float conversions) is stipulated.
Benchmarks of old sscanf():
~~~~~~~~~~~~~~~~~~~~~~~~~~
AVR: at90s8515__________________________ atmega8____________________________
GCC: 3.3.6 3.4.6 4.0.4 4.1.2 4.2.2 4.3.X 3.3.6 3.4.6 4.0.4 4.1.2 4.2.2 4.3.X
-------------------------------------------------------------------------------
sscanf_min("12345","%d",&x)
Flash: 1356 1354 1374 1372 1386 1392 1222 1222 1238 1240 1250 1254
Stack: 49 49 53 53 59 55 49 49 53 53 59 55
Time: 1681 1672 1640 1638 1643 1685 1371 1367 1359 1357 1356 1392
-------------------------------------------------------------------------------
sscanf_std("12345","%d",&x)
Flash: 1680 1672 1796 1762 1736 1764 1512 1504 1588 1562 1552 1558
Stack: 50 50 54 54 61 56 50 50 54 54 61 56
Time: 1715 1736 1714 1694 1749 1751 1413 1434 1432 1417 1461 1463
-------------------------------------------------------------------------------
sscanf_flt("1.2345","%e",&x)
Flash: 4022 3982 4078 4002 4108 4360 3676 3636 3682 3646 3746 3976
Stack: 124 124 126 128 140 132 124 124 126 128 140 132
Time: 3026 3025 3023 3043 3104 3165 2651 2651 2652 2673 2729 2778
===============================================================================
Benchmarks of new sscanf():
~~~~~~~~~~~~~~~~~~~~~~~~~~
AVR: at90s8515__________________________ atmega8____________________________
GCC: 3.3.6 3.4.6 4.0.4 4.1.2 4.2.2 4.3.X 3.3.6 3.4.6 4.0.4 4.1.2 4.2.2 4.3.X
-------------------------------------------------------------------------------
sscanf_min("12345","%d",&x)
Flash: 1522 1482 1442 1368 1428 1388 1312 1278 1260 1186 1244 1186
Stack: 52 52 54 53 55 52 52 52 54 53 55 52
Time: 1476 1477 1358 1360 1339 1500 1359 1359 1260 1261 1240 1361
-------------------------------------------------------------------------------
sscanf_std("12345","%d",&x)
Flash: 1926 1894 1926 1836 1838 1802 1660 1632 1686 1596 1594 1540
Stack: 52 52 53 51 53 52 52 52 53 51 53 52
Time: 1480 1481 1357 1355 1334 1503 1363 1363 1259 1256 1235 1364
-------------------------------------------------------------------------------
sscanf_flt("1.2345","%e",&x)
Flash: 3506 3454 3304 3162 3186 3232 3064 3020 2880 2788 2808 2834
Stack: 60 60 69 61 63 60 60 60 67 61 63 60
Time: 2337 2351 2353 2179 2187 2355 1961 1967 1924 1826 1833 1962
===============================================================================
Dmitry.
- [avr-libc-dev] Plans to update scanf().,
Dmitry K. <=