The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: raymond on April 04, 2005, 04:51:09 PM

Title: BCD tutorial
Post by: raymond on April 04, 2005, 04:51:09 PM
I am currently working on a short tutorial covering the use of the BCD (Binary Coded Decimal) instructions. The introduction and the aaa instruction are completed but I may not have much time to continue with the other 5 instructions before another 2-3 weeks.

Meanwhile, any comment on the style, content, etc. would certainly be appreciated so that I can take those into consideration for the description of the other instructions (and even for what has already been done).

When completed, the entire tutorial will be made available for download as a zipped file in addition to on-line consultation.

You can examine the initial part at the following:

http://www.ray.masmcode.com/BCDtut.html

Raymond
Title: Re: BCD tutorial
Post by: pbrennick on April 04, 2005, 06:21:36 PM
Raymond,
Very concise and well laid out.  I can't wait to see the finished product.  This is the type of thing that will help beginners get up to speed.

Paul
Title: Re: BCD tutorial
Post by: RuiLoureiro on April 04, 2005, 08:19:04 PM
Hi Mr Raymond

  Thank you for mathschallenge.net site. It is interesting. My son already know. I am studying masm32 documentation !

stay well
RuiLoureiro
 
Title: Re: BCD tutorial
Post by: sluggy on April 05, 2005, 09:26:29 AM
Yes, good tutorial  :U
Title: Re: BCD tutorial
Post by: raymond on April 27, 2005, 11:46:25 PM
What a few rainy days alone can do to get work done!! :bg

The version 1.0 of the tutorial is completed and available for consulting or download at:

http://www.ray.masmcode.com/index.html#bcds

Two programs of mine using BCDs are also included with their source code in the downloadable zipped file.

Any comment for clarifications, improvements, etc. will be greatly appreciated.

Raymond
Title: Re: BCD tutorial
Post by: hutch-- on April 28, 2005, 03:51:39 AM
Ray,

Compliments on the latest addition to your already very good technical data. Its a pleasure to see this standard of technical data available written so clearly.  :U
Title: Re: BCD tutorial
Post by: Mark Jones on April 28, 2005, 03:56:05 PM
 Awesome work, thanks! :bg

I memorized this example of FP math, dunno where this falls in your binary examples but maybe it is useful. (16 bits resolution, +0.00 to +255.99 format, round any thousandths remainder:)


1/2   = 0.50000000
1/4   = 0.25000000
1/8   = 0.12500000
1/16  = 0.06250000
1/32  = 0.03125000
1/64  = 0.01562500
1/128 = 0.00781250
1/256 = 0.00390625 (could be used as sign flag instead)

Decimal:                            214.78
          128  64  32  16  8  4  2  1  . 1/2  1/4  1/8  1/16  1/32  1/64  1/128  1/256
Binary:    1   1   0   1   0  1  1  0  .  1    1    0    0     0     1     1      1
Hexidecimal:                         D6 C7
Actual:                             214.77734375

Title: Re: BCD tutorial
Post by: raymond on April 29, 2005, 02:03:12 AM

Quotedunno where this falls in your binary examples but maybe it is useful
It actually would fall much more in my section dealing with fixed point math (which you can find on the same site). The available library of functions is based on 32 bits, 1 bit for the sign (bit 31 as for normal integers) followed by 15 bits for the integer (-32767 to +32767), and 16 bits for the fractional portion (+/-0.00001).

The "mixed" numbers are handled the same as regular integers for adding and subtracting, and almost the same for multiplying and dividing, all with CPU instructions. Converting to/from ASCII/"mixed" is also relatively easy.

Raymond