News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

BCD tutorial

Started by raymond, April 04, 2005, 04:51:09 PM

Previous topic - Next topic

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

pbrennick

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

RuiLoureiro

Hi Mr Raymond

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

stay well
RuiLoureiro
 

sluggy

Yes, good tutorial  :U

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

hutch--

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
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

 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

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

raymond


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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com