O'Reilly logo

32/64-Bit 80x86 Assembly Language Architecture by James Leiterman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Binary-Coded Decimal (BCD)

Converting an ASCII string to binary-coded decimal is as easy as pie (or is it a piece of cake?). In BCD, for every byte, the lower 4-bit nibble and upper 4-bit nibble each store a value from 0 to 9 (think double-digit hex only the upper six values A through F are ignored).

Workbench Files:\Bench\x86\chap15\project\platform

 

project

platform

ASE to VMP

\ase2vmp\

\vc6

BCD 2N

\bcd\

\vc.net

BCD

Table 15-1. ASCII numerical digit to hex and decimal values

ASCII

0

1

2

3

4

5

6

7

8

9

Hex

0x30

0x31

0x32

0x33

0x34

0x35

0x36

0x37

0x38

0x39

Decimal

48

49

50

51

52

53

54

55

56

57

BCD

0

1

2

3

4

5

6

7

8

9

Binary

0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

Converting a BCD value from ASCII to a nibble is as easy as subtracting the hex value of 0x30, '0', or 48 decimal from the ASCII ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required