Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why BCD instructions were removed in AMD64? [duplicate]

Binary Coded Decimal Instructions are part of the x86 architecture at least from the i8086. They are like AAA, DAA, AAS, DAS, and help to work with arithmetic operations on BCD numbers.

Here is some reference of them:

https://en.wikipedia.org/wiki/Intel_BCD_opcode

According to Intel's Software Developer's Manual. Those instructions are not available in long (64 bits) mode. I'm know maybe the only people that actually know why are the designers of the architecture, but why do you think they remove them?

like image 758
felknight Avatar asked Oct 17 '15 03:10

felknight


People also ask

Why is BCD inefficient?

BCD encodes each decimal digit with its binary equivalent using four bits. So decimal digits are simply represented in four bits by their direct binary values. A disadvantage of this is that only 10 of the possible 16 (24) codes that four bits can produce are used. Hence it is an inefficient code.

Why are BCD codes required?

The main advantage of the Binary Coded Decimal system is that it is a fast and efficient system to convert the decimal numbers into binary numbers as compared to the pure binary system. But the BCD code is wasteful as many of the 4-bit states (10-to-16) are not used but decimal displays have important applications.

What is BCD instruction?

In computing and an electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used for a sign or other indications (e.g. error or overflow).

Why do processors use BCD representation?

BCD not only guaranteed that you could look at particular areas of a byte to find an individual digit - which is useful sometimes - but also allowed the hardware to apply simple rules to calculate the required precision and scale for e.g. adding or multiplying two numbers together.


1 Answers

The answer is in your link:

Adding BCD numbers using these opcodes is a complex task, and requires many instructions to add even modest numbers. It can also require a large amount of memory.

All integer calculations are exact, so the radix of the number representation is not important for accuracy. Therefore, even financial software today usually stores values in binary representation and only converts to decimal for input and output.

On an x86 processor calculations with binary numbers are usually a lot faster than the same calculations with BCD numbers.

as to why the opcodes are removed from x86_64 even though the capability is still present in the hardware (though likely implemented in microcode) per Raymond Chen's comment:

They free up valuable 1-byte opcodes for future use.

like image 84
gordy Avatar answered Nov 15 '22 11:11

gordy