|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) binary subtraction
A realization of binary subtraction (4 bits) on the i4004 microprocessor
based on this assembly source: sub.asm.
; sub.asm ; subtract two 4bit numbers on the Intel 4004 FIM R0R1, 0x35 ; initialize R0=5 & R1=3 FIM R2R3, 0 ; clear R2R3 (unused) LD R0 ; load R0 into accumulator SUB R1 ; subtract second number XCH R1 ; and store in R1 done: JUN done ; end
Yet another short program fragment, showing a single 4-bit binary subtraction.
The program first executes an FIM load immediate instruction to initialize the source registers (here, R0=5 and R1=3). We also initialize the register pair R2R3 (R2=0 and R3=0), allthough these are not used at all by this program (they will be used in the next program, showing the BCD subtraction). The program then loads R0 into the accumulator, subtracts the contents of R1 from the accumulator, and stores the result into R1. Finally, the program 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.)
Yet 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)|