|TAMS / Java / Hades / applets: contents | previous | next|
adders and arithm...
LFSR and selftest
I/O and displays
CMOS circuits (sw...
Mips R3000 cosimu...
Intel MCS4 (i4004)
MCS4 binary ...
MCS4 BCD add...
MCS4 binary ...
MCS4 BCD sub...
MCS4 RAM add...
MCS4 RAM sub...
MCS4 I/O ports
image processing ...
[Sch04] RALU, Min...
|Intel MCS4 (i4004) BCD addition
A realization of BCD addition on the i4004 microprocessor
based on this assembly source: bcd_add.asm.
; bcd_add.asm ; add two 4bit binary-coded decimal numbers on the Intel 4004 ; bcd-wise FIM R0R1, 0x78 ; initialize R0=8 & R1=7 FIM R2R3, 0 ; clear result pair LD R0 ; load R0 into accumulator ADD R1 ; add second number DAA ; decimal adjust accumulator XCH R2 ; store new result in R2 TCC ; transfer carry to accumulator XCH R2 ; store new result in R3 done: JUN done ; end
This short program demonstrates a single BCD addition on the i4004 with help of the DAA instruction. As the MCS4 system was originally designed for a printing desktop calculator, binary-coded-decimal arithmetic was one of the main application areas of the MCS4.
The program first executes to FIM load immediate instructions to initialize the source registers (R0=8 and R1=7), as well as the result registers (R2=0 and R3=0). The program then loads R0 into the accumulator, adds the contents of R1 to the accumulator. The next instructions, DAA, performs the decimal adjustment and updates the carry flag. We then store the addition result into register R2. Afterwards, we use the TCC instruction to transfer the carry bit into the accumulator and another XCH instruction to store write R3. The program then enters an endless loop, written as a JUN (jump unconditional) instruction that jumps to its own address.
To watch the program execution, open the user-interface of the i4004 processor and the i4001 ROM chip memory editor. (On Windows, you may have to resize and move the windows a little, so that all windows remain readable during the simulation.)
Again, you may want to single-step through the program
with the technique explained in the MCS4 overview,
because the program is so short.
Type the value
|Print version | Run this demo in the Hades editor (via Java WebStart)|
|Usage | FAQ | About | License | Feedback | Tutorial (PDF) | Referenzkarte (PDF, in German)|