Please note that JavaScript and style sheet are used in this website,
Due to unadaptability of the style sheet with the browser used in your computer, pages may not look as original.
Even in such a case, however, the contents can be used safely.
FAQ-ID : 78cor-0001Last Updated : 2008/01

|
Coffee Break Decimal adjustment is done using the contents of register A, a carry flag and an auxiliary carry flag. Actual adjustment is performed by dividing the contents of register A into higher four bits and lower four bits (this division is done for each decimal number digit). In the case of addition, either when the result value is A to F or when carry occurs (when carry or auxiliary carry is set), 6 is added to the four bits (or else, 0 is added). The result is reflected to register A and the carry flag. Since the addition is executed between the same degits of decimal numbers, [addition result = A to F] and [carry] never occur simultaneously. For details about decimal adjustment, refer to Sample arithmetic operation program for CPUs that do not have a decimal adjust instruction. |
|
Coffee Break There are a number of decimal calculation methods. In terms of instructions, the use of decimal addition and decimal subtraction instructions is one approach, and the use of adjustment is another one. In the majority of cases, decimal adjustment is employed. The 8080 family, the first generation of 8-bit microprocessors, used decimal adjust instructions for addition only, and performing subtractions in decimal required quite a lot of processing. Subsequent microprocessors that improved this point provided a flag indicating whether addition or subtraction was performed, enabling both addition and subtraction with one adjust instruction. This latter version was clearly easier to use, but since the former version was used in the market, the latter version gained little acceptance due to compatibility issues. Later, the Z80 was launched and the improved design featuring an additional flag became common. The method adding a flag was born from the need to be able to continue using existing software. Free from the constraint of existing software, the approach of the current 78K0 employing a adjust instruction for addition and a adjust instruction for subtraction allows a simpler configuration because it does not require the use of extra flags. |