| ||
ASCII |
| 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 |
| 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 numerical value and get the resulting value with a range of {09}.
byte ASCIItoBCD(char c) { ASSERT(('0' <= c) && (c <= '9')); return (byte)(c - '0'); }
No 64-bit | The general-purpose BCD instructions are not available in 64-bit mode. |
When the 8086 processor was first manufactured the FPU was a separate optional chip (8087). There was a need for some BCD operations similar to other processors and so it was incorporated into the CPU. The 8087 had some BCD support as well. When the 64-bit processor was developed, it was decided that BCD support was not required anymore as the FPU was an alternative method.
The FPU uses the first nine bytes to support 18 BCD digits. The uppermost bit of the 10 th byte indicates the value is negative if set or positive if the bit is clear.
Setting the upper nibble of a byte is merely the shifting left of a BCD digit by four bits, then logical ORing (or suming) the lower nibble.
byte BCDtoByte(byte lo, byte hi) { return (hi << 4) lo; }
Mnemonic
P
PII
K6
3D!
3Mx+
SSE
SSE2
A64
SSE3
E64T
DAA
EAN: 2147483647
Pages: 191
If you may any questions please contact us: flylib@qtcs.net