flat assembler
Message board for the users of flat assembler.
Index
> Main > looking for bin2bcd |
Author |
|
vid 22 Apr 2004, 08:31
just wondering - what are you going to use BCDs for?
|
|||
22 Apr 2004, 08:31 |
|
spo 22 Apr 2004, 14:44
Well, my brother has to do a homework using BCD arithmetics. I know BCD isn't being much used these days, but sometimes someone has to deal with it. anyway, thanks for asking
|
|||
22 Apr 2004, 14:44 |
|
vid 22 Apr 2004, 18:17
general algorithm is something like this (in C):
//store n as BCD at buffer at dest //unsigned int n; //unsigned int *dest; do{ low = n % 10; n = n / 10; high = n % 10; n = n / 10; *dest = (high << 16) | low; dest++; } while (n>0) size of buffer pointed by dest depends on size of "int". If int is 16bit, buffer must hold 5 decimal digits (65535), that means 3 bytes. For 32bits, it must hold 10 digits (4294967296), that means 5 bytes. I hope this code is right and you can code in C, i don't have enough time to write & test ASM code. |
|||
22 Apr 2004, 18:17 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.