Skip to content
EyeBool edited this page Jan 17, 2018 · 4 revisions

Now we learned a bit about i4004 architecture and we know that it contains Accumulator and 16 General Registers. Let us try few instructions on these memory cells.

We will use simple online emulator for our experiments. You can also download its offline version (which could be run with Python).

Load value and Exchange

Consider the following program:

ldm 5
xch r2

It consists of two instructions, each of them is written in separate line. LDM is abbreviation for "Load Immediate" - i.e. load immediately defined value directly to Acc. XCH stands for "Exchange" - i.e. swap values between Acc and some register. Both of these instructions use 1 operand - the value to load and the register to exchange with.

If we rewrite this code in Python it will look like this:

acc = 5
r2, acc = acc, r2

Let us run it in emulator - use this link.

Here you see large code area (it should be loaded with our small program) on the left and few more controls on the right. For now their sense is as following:

  • input shows the contents of 16 registers (from r0 to r15) - initially all of them are zeroes;
  • run button allows you to execute your code (try it);
  • output will (after execution) show the results - the same 16 registers.

After running the program you should notice that output shows the value for r2 changed to 5. Really it is what we have expected of our first program.


Next: Learn about other Assignment Instructions