-
Notifications
You must be signed in to change notification settings - Fork 14
Memory related instructions
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
-
SRCcommand ("send register control" - or as for me just "source") copies8bit from supplied register pair to special data pointer (i.e.src r2- set data pointer to value ofr2: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
-
WRMsends data from accumulator to the chosen memory cell (i.e.memory[dp] = acc) -
RDMreads data from memory cell to accumulator (i.e. `acc = memory[dp]) -
ADMadds memory cell to accumulator (similar toADD) -
SBMsubtracts memory cell from accumulator (similar toSUB)
Arithmetic instructions ADM and SBM treat the Carry flag in exactly the same way as ADD and SUB.