The instruction set of the REPLiCa programming language contains 62 instructions in total, as listed below. The user is able to include and exclude any of these instructions from the available instruction set for any particular run of the system, according to the specification of the genetic code in the input file genetic_code.ini (described in Section A.5).
In the following description of the instructions, RMS stands
for Received Message Store, CWM for Communications Working
Memory, and NWM for Nucleus Working Memory.
ADRString refers to the string pointed to by
ADRStringPointer (mentioned in
Section 4.3.8); this is the
InfoString upon which the adr and
mov_ic instructions will act. This
may be the cell's own genome, or it may be a message in the cell's
Received Message Store. ADRStringPointer can be changed to point to a
different InfoString with the str_switch
and similar instructions. A register enclosed in square brackets (e.g. [ax]
) indicates the contents of the memory location specified
by the value of that register.
Some of the instructions relating to regulators (e.g. reg_create), and to searching for binding sites (e.g. adr), must be immediately followed by a valid binding site specification if they are to operate correctly. A valid specification is a consecutive string of nop instructions (i.e. taken from the set {nop_00, nop_01, nop_10, nop_11}).
A few instructions involve actions which occur in a particular direction relative to the cell executing them (e.g. move, et_transport). In these cases, the direction is specified by the low 3 bits of the cx register. This gives a number between 0 and 7, which corresponds to the directions shown in Figure 4.3(a).
push_a ; push ax onto stack push_c ; push cx onto stack pop_a ; pop stack into ax pop_c ; pop stack into cx swap_ab ; ax=bx, bx=ax swap_cd ; cx=dx, dx=cx mov_ic ; copy one instruction from ADRString, starting ; from address [ax], into cx. The length of the ; instruction copied is written to dx. ax += dx. ; If ax>length of ADRString, flag=true. clr_f ; flag=false inc_a ; increment ax (if overflow, flag=true) inc_c ; increment cx (if overflow, flag=true) dec_c ; decrement cx (if underflow, flag=true) add_cd ; cx=cx+dx (if overflow, flag=true) sub_cd ; cx=cx-dx (if underflow, flag=true) sub_ab ; cx=ax-bx (if underflow, flag=true) zero_c ; cx=0 not_c ; cx=NOT cx (bitwise) and_cd ; cx=cx AND dx (bitwise) or_cd ; cx=cx OR dx (bitwise) shl_c ; shift bits in cx left ; (lo bit <- flag, hi bit -> flag) shr_c ; shift bits in cx right ; (hi bit <- flag, lo bit -> flag) not_lo_c ; flip low bit of cx
if_fl ; if (flag=false) increment instruction pointer ; otherwise do nothing if_not_fl ; if (flag=true) increment instruction pointer ; otherwise do nothing if_z ; if (cx!=0) increment instruction pointer ; otherwise do nothing stop ; stop execution and unbind current promoter set_jmp ; point the local jump marker to the next ; instruction clr_jmp ; clear the local jump marker jmp ; if local jump marker is set, jump to that ; instruction, otherwise do nothing (set flag=true)
nwm_clear ; Erase the NWM WritableInfoString nwm_write ; Copy first n bits of cx to the end of the NWM, ; where n is given by the low 4 bits of dx. nwm_write_bit ; Copy the first bit of cx to the end of the NWM. nwm_divide ; Create a new single-celled organism by copying ; NWM WritableInfoString as the new genome, ; splitting the contents of the regulator stores ; and Energy Token store, and creating an initially ; empty RMS and CWM. The NWM of parent cell is ; empty after the division. Child cell is placed ; randomly at a free location near the parent (no ; preferred direction). nwm_split ; Transfer contents of NWM into a new cell which ; will become an additional process of the ; multicellular organism. Child cell is placed in a ; position relative to the parent specified by the ; low 3 bits of the cx register. If this location ; is already occupied, the nearest free neighbour ; is occupied. If all 8 neighbours are occupied, ; child cell replaces the parent (parent dies).
cwm_clear ; Erase the CWM WritableInfoString cwm_write ; Copy first n bits of cx to the end of the CWM, ; where n is given by the low 4 bits of dx. cwm_write_bit ; Copy first bit of cx to the end of the CWM. cwm_send ; Transfer contents of CWM to an ; EnvironmentalInfoString at the current grid ; position of the cell, with a type given by the ; low 4 bits of dx. The msg is given a standard ; intensity. This msg replaces any existing msg at ; that grid posn with the same msg type. After the ; instruction is issued, the CWM is emptied. If ; another cwm_send is sent within n time slices of ; the last one (and msg type is the same, and CWM ; is now empty), the intensity of the existing msg ; at that grid pos with msg type=dx is increased ; (by a standard amount).
rms_receive ; Receive msg(s) from environment. One execution of ; this instruction will search over a catchment ; area of 1/8th of a full circle (45 degrees), in a ; direction specified by the low 3 bits of the cx ; register. The search is for messages of String ; type specified by the low 4 bits of the dx ; register. Each search initially spreads out from ; the cell and covers a fixed number (n) of grid ; cells (specified by the parameter ; rms_receive_search_area) and all msgs of the ; right type are received and added to the end of ; the RMS. If another rms_receive is issued for the ; same String type and same direction within a ; fixed number of time slices (specified by the ; max_time_for_msg_receive_reinforcement ; parameter), the current search continues outwards ; (covering n more grid positions).
et_collect ; if (environmental energy token available) ; pick up n tokens from environment ; (n specified by global parameter ; number_of_energy_tokens_per_collect) ; else ; flag=true et_transport ; if ((number of tokens in store >= ; ets_lower_threshold) ; && ; (there is a cell belonging to the same ; organism in the direction indicated by the ; lower 3 bits of cx)) ; send n tokens to neighbouring cell in ; direction indicated (n specified by ; the global parameter ; number_of_energy_tokens_per_collect) ; else ; flag=true et_check ; cx=current level of energy token store
[the following instructions all work for both promoters and repressors. To work correctly, they must both be followed by two or more nop's. The first nop specifies whether a promoter or a repressor is being referred to (nop_00 and nop_01 indicate a promoter, and nop_10 and nop_11 a repressor). The second and subsequent nop's specify the binding pattern of the regulator.] reg_destroy ; if ((valid binding site specification follows ; instruction) && ; (a matching regulator exists in the store)) ; remove one of the matching regulators ; else ; flag=true reg_transport ; if ((valid binding site specification follows ; instruction) && ; (a matching regulator exists in the store) && ; (there is a cell belonging to the same ; organism in the direction indicated by the ; lower 3 bits of cx)) ; send one matching regulator to neighbour ; cell indicated (removing it from store in ; first cell). ; else ; flag=true reg_create ; if two or more nop's follow, create a regulator ; from the specified bit pattern and place it in ; the appropriate regulator store. If the first nop ; is a nop_00 or a nop_01, create a promoter with ; bit pattern specified by the second and ; subsequent nop's, and place it at the bottom of ; the list in the Promoter Store. Otherwise (if the ; first nop is a nop_10 or a nop_11), create a ; repressor with bit pattern specified by the ; second and subsequent nop's, and place it in the ; Repressor Store, checking for possible binding ; sites on the Genome (and other eligible ; InfoStrings in the Received Message Store).
nop_00 ; symbols for specifying binding sites (used in nop_01 ; creating promoters and repressors, and by nop_10 ; adr instructions) nop_11 ;
adr ; if ((valid binding site specification follows ; instruction) && ; (a matching binding site is found on the ; ADRString)) ; ax = address of the memory location ; immediately succeeding the ; nearest matching template ; else ; flag=true adrf ; as adr, but only searches forwards from current ; position of read-head on ADRString adrb ; as adr, but only searches backwards from current ; position of read-head on ADRString str_switch ; if (there exists an InfoString with type=low 4 ; bits of dx) ; ADRString=first matching String found ; else ; flag=true str_switchf ; as str_switch, but only searches forwards from ; current ADRString str_switchb ; as str_switch, but only searches backwards from ; current ADRString str_host ; ADRString=cell's genome String str_latest ; ADRString=last String in RMS list str_next ; ADRString=next String in RMS list. If at end, ; loop back to the cell's genome String. If on the ; genome String, move to first String in RMS. str_previous ; ADRString=Previous String (i.e. just the ; reverse of the action of str_next) str_remove ; if (there exists an InfoString with type=low 4 ; bits of dx in the RMS) ; remove first matching string found ; else ; flag=true
move ; Attempt to move cell (and whole organism) in the ; direction specified by the low 3 bits of the cx ; register. For multicellular organisms, each cell ; that issues a move instruction during a time ; slice is actually casting a vote for the desired ; direction of movement. The overall effect of this ; is given by a formula described elsewhere. migrate ; Attempt to move cell relative to other cells in ; the organism in a direction specified by the low ; 3 bits of the cx register. If direction if full, ; nearest free direction is taken. If no free ; direction is available, migration has no effect ; (flag=true). Note that migration for a single ; celled organism has the same effect as a move ; instruction.
kill ; Kill current cell. Any energy tokens in the ; cell's Energy Token Store are added to the ; current grid position's store. Note that if cell ; was part of a multicellular organism, cell death ; may lead to the organism physically breaking up ; into two or more distinct organisms.