33
votes
Why does the Z80 have a half-carry bit?
The intermediate carry flag, or "adjust flag", or half-carry flag is used to facilitate binary-coded decimal (BCD) arithmetic, where each decimal digit of a number is represented as a nibble ...
26
votes
Accepted
Did the NES CPU save die area by omitting BCD?
TL;DR: No.
The NES CPU was a copy of the 6502
The 6502 section of the Ricoh RP2A03 is a very close (*1) copy as comparing the images show
(Images sourced from Wikipedia (RP2A03) and Visual 6502. ...
21
votes
Protecting 6502 decimal mode code from interrupts
TL;DR:
Protecting 6502 decimal mode code from interrupts
Decimal mode does not need to be protected from interrupts.
Decimal mode is not cancelled/changed by interrupt routines(*1).
Decimal mode is ...
17
votes
Accepted
Did any micros use the 6502 BCD mode in their OS?
(Only partly my answer, as the important list is a collection of what has been found and noted by others in comments to the question - I thought putting it in an answer would be helpful to others ...
16
votes
Accepted
What is the relationship between the Ricoh 2A03 and the MOS 6502?
The Ricoh 2A03 (NTSC) and 2A07 (PAL) are best thought of as ASIC devices. They include a 6502-compatible CPU core, but these chips also include the NES's 5-voice Programmable Sound Generator. The ...
14
votes
Accepted
Were any decimal-based computers capable of handling text?
Really early computers like the Mark I and ENIAC didn't have enough memory to attempt to handle text; also the use-case was mostly calculations.
A number of decimal IBM computers used characters (with ...
13
votes
Accepted
3 decimal digits per 10 bits
Yes; it's called Chen-Ho encoding
Theodore M. Hertz of Rockwell filed for a patent on a similar encoding in 1969. The patent was granted in 1971.
Independently in 1971, IBM researchers Tien Chi ...
11
votes
Accepted
Why does the Z80 have a half-carry bit?
Why does the Z80 have a half-carry bit?
Because the ALU is only 4 bits wide. The Z80 needs to preserve the carry between bits 3 and 4.
Why did the designers of this chip choose to preserve that ...
11
votes
Reason behind "ASCII Adjust" instructions being ASCII and not BCD?
The “ASCII” instructions are really about unpacked BCD, not ASCII. There is some justification for calling them “ASCII”, because unpacked BCD can easily be converted to and from ASCII, and in fact if ...
9
votes
Did the NES CPU save die area by omitting BCD?
AFAIK the circuitry was not removed, it was only "damaged" enough to stop working. So no area gains/etc., neither the layout was redone.
Well the part about layout might be not completely ...
8
votes
What does the DAA instruction do?
The DAA instruction on 6800 just works on the accumulator based on the data it contains and the flags register as set by the previous instructions.
So it does not know what instruction it was and ...
8
votes
Accepted
What instructions for the 8086 and subsequent x86 CPUs are not available in Long Mode?
Other than changed immediate operand lengths (to support 64-bit addresses) and register encodings (to support the new registers), which obviously make practically all code incompatible at the binary ...
8
votes
6502: is BCD *fundamentally* the same performance as non-BCD?
But beyond that, is there any fundamental difference in performance?
On a fundamental base: No.
In code looping and adjusting needs to take into account that digits are shifted by 4 instead of 1 and ...
5
votes
3 decimal digits per 10 bits
It is well-known that binary floating point is unsuitable for financial applications, because 0.1 is not exactly representable in binary.
It's less the binary part, than floating point in general. ...
5
votes
Accepted
6502: is BCD *fundamentally* the same performance as non-BCD?
Let's write some actual code for fixed point arithmetic and see how it goes.
1) Addition and Subtraction is obviously fundamentally the same.
2) Multiplication. There are quite a few ways to do ...
4
votes
Accepted
Protecting 6502 decimal mode code from interrupts
Prohibiting interrupts around a decimal mode operation is a pattern to protect the interrupt service routine, not the decimal code sequences.
As was already emphasized by others, an interrupt ...
4
votes
Protecting 6502 decimal mode code from interrupts
There's absolutely no reason for an interrupt service routine to save and restore the decimal flag - On interrupt, the flag is being saved to the stack automatically, and restored on RTI, so any "...
4
votes
Accepted
The 8086 has AAM (ASCII Adjust after Multiply), why not the same for packed BCD?
To adjust a value, one needs to know how many carries there were out of each decimal digit. When adding two 8-bit numbers, there can be at most one carry out of each 4-bit chunk, which will fit in ...
4
votes
Did any micros use the 6502 BCD mode in their OS?
The KIM Math package used packed BCD for storage and unpacked decimal for computation. I used to have a vintage bound copy of the source code, but sold it to a collector. I have no idea whether any ...
4
votes
Why does the Z80 have a half-carry bit?
The Intel 4004 and 4040 were 4-bit CPUs. In some ways, the 8008 and its successor, the 8080 behaved as if it were two 4004s glued together, although the 8008 architecture was not just two 4004s glued ...
3
votes
Why does the Z80 have a half-carry bit?
The reason there needs to be a visible "half carry" bit is a combination of two factors.
BCD support
Interrupt handling.
As other answers have pointed out the Z80 provided BCD support through an ...
3
votes
Reason behind "ASCII Adjust" instructions being ASCII and not BCD?
On the 8086, an 8-bit quantity can represent a number in four ways. Of these four, unpacked BCD is the closest to direct representation by ASCII. The AAx instructions are needed to use this ...
2
votes
3 decimal digits per 10 bits
The IBM floating point representation had a hexadecimal exponent — in other words, it used 4-bit units in the mantissa field. It was widely criticized for its "wobbling precision". What you're ...
2
votes
Did any micros use the 6502 BCD mode in their OS?
Visicalc for the Apple II used "a variation of decimal arithmetic" which I assume means BCD.
The reason they give is the same reason decimal arithmetic was used on mainframes:
[...] so all money ...
2
votes
The 8086 has AAM (ASCII Adjust after Multiply), why not the same for packed BCD?
AAM is needed because the result of multiplying two unpacked BCD is a 'strange' value that needs to be 'normalized' again.
The whole mechanic of using the binary multiply with BCD only woks with '...
1
vote
Were any decimal-based computers capable of handling text?
Singer made a series of retail systems which were taken over by ICL and rebranded.
The ICL System 10 used 6-bit bytes for decimal and character data.
The ICL System 25 used 8-bit bytes, which were ...
1
vote
6502: is BCD *fundamentally* the same performance as non-BCD?
Yes, there are differences in the algorithms used for BCD compared with binary arithmetic. The code for BCD is more complex, so larger and probably slower, if implemented with roughly equivalent ...
1
vote
Reason behind "ASCII Adjust" instructions being ASCII and not BCD?
Preface: Before writing anything that I got it wrong, it might be helpful to take a look at the original documentations instead of refering some web page, as there are TONS out there who got that part ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
binary-coded-decimal × 126502 × 5
assembly × 3
nes × 2
cpu × 2
intel × 2
8086 × 2
hardware × 1
z80 × 1
chip × 1
x86 × 1
text × 1
early-computer × 1
6800 × 1
6809 × 1
character-sets × 1
biquinary × 1
cpu-flag-bits × 1