Skip to content

Memory related instructions

wassekaran edited this page Apr 1, 2018 · 3 revisions

Since we have learned many useful instructions to deal with internal registers and control the flow of the execution - we may wonder: how can this tiny chip work with external memory?

Though Intel 4004 CPU can work without external RAM at all thanks to its 16 registers - but they are not enough for more complicated tasks. So one or more memory chips could be wired to the processor. In this case special commands are used to deal with data stored outside.

###Setting data pointer

  • SRC command ("send register control" - or as for me just "source") copies 8 bit from supplied register pair to special data pointer (i.e. src r2 - set data pointer to value of r2:r3)

All further instructions will work with Accumulator and data cell pointed by this data pointer. So if you want to move to another cell, you'll need to call SRC once more.

Each memory cell is 4-bits large and we can address 256 of them.

###Working with memory cell

  • WRM sends data from accumulator to the chosen memory cell (i.e. memory[dp] = acc)
  • RDM reads data from memory cell to accumulator (i.e. `acc = memory[dp])
  • ADM adds memory cell to accumulator (similar to ADD)
  • SBM subtracts memory cell from accumulator (similar to SUB)

Arithmetic instructions ADM and SBM treat the Carry flag in exactly the same way as ADD and SUB.


Next: Special Instructions