flat assembler
Message board for the users of flat assembler.

Index > Main > Do you use BCDs?


Do you use BCDs?
Yes
44%
 44%  [ 4 ]
No
55%
 55%  [ 5 ]
What is a BCD?
0%
 0%  [ 0 ]
Total Votes : 9

Author
Thread Post new topic Reply to topic
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper 05 Jan 2013, 18:44
Just curious...

_________________
Ciper
Post 05 Jan 2013, 18:44
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 05 Jan 2013, 19:27
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:05; edited 1 time in total
Post 05 Jan 2013, 19:27
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 05 Jan 2013, 19:55
Ciper,

Packed BCDs are quite useful when "USAGE IS DISPLAY" (in COBOL-speak). FASM internally uses unpacked BCZ (radix 36 numbers in their ASCII representation) for macro-local symbols' trailer.

These (almost forgotten) aaa/aad/aam/aas/daa/das instructions provide compact, while slow, methods to handle them well. OTOH, das was made popular by famous 5-byte sequence to convert nibble to its hex ASCII representation.

There is fbstp instruction for quick'n'dirty conversion to decimal representation, too.
Post 05 Jan 2013, 19:55
View user's profile Send private message Reply with quote
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper 05 Jan 2013, 20:22
baldr,

Thank you very much for these clarifications; I believe people and (more seriously) compilers have discarded them too soon; most run-time libraries are certainly slower than these instructions.

_________________
Ciper
Post 05 Jan 2013, 20:22
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 05 Jan 2013, 20:37
Ciper,

Those aren't clarifications of any sort, I'd just pointed out that data usage dictates its representation. For computation-heavy usage, binary can be optimal; if you intend to convert them to textual (or any other) representation often, BCD (or any other easily converted to ASCII/other) representation can give your program sensible boost.

Those instructions are invalid in 64-bit code anyway (except fbstp, naturally Wink).
Post 05 Jan 2013, 20:37
View user's profile Send private message Reply with quote
Ciper



Joined: 01 Jan 2013
Posts: 27
Ciper 05 Jan 2013, 20:45
baldr,

Retracting the 'clarifications' qualification...

_________________
Ciper
Post 05 Jan 2013, 20:45
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 06 Jan 2013, 02:19
Never found a suitable time to use it until recently when comparing lots of ASCII decimal output, switching to hex diff saved some space and time.
Post 06 Jan 2013, 02:19
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 06 Jan 2013, 04:47
cod3b453,

Comparison is probably not a good example of decimal-oriented data representation usage. Exach matching of arbitary strings can be processed (with good hash function) efficiently; most scripting languages use that technique to compare strings in almost O(1) time.
Post 06 Jan 2013, 04:47
View user's profile Send private message Reply with quote
pool



Joined: 08 Jan 2007
Posts: 97
pool 06 Jan 2013, 11:32
..


Last edited by pool on 17 Mar 2013, 12:20; edited 1 time in total
Post 06 Jan 2013, 11:32
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 06 Jan 2013, 12:22
@baldr: My example wasn't about the comparison as much as the space usage - moving from (n+2) ASCII digits to n BCD digits simply meant 2-3 times less data to be stored/loaded from disk; hence faster to compare and less of a dent in my disk quota Razz
Post 06 Jan 2013, 12:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.