diff --git a/codes/selectedNot.asm b/codes/selectedNot.asm index e69ac45..fc3b737 100644 --- a/codes/selectedNot.asm +++ b/codes/selectedNot.asm @@ -6,8 +6,8 @@ define: # BIT NOT selector - 0 [ABC][DE][NSE] - 1 [ABCD]{E}[NSE] + 0 [ABC][DE][NSE]. + 1 [ABCD]{E}[NSE]. NO [ABC][DE]{NSE} Nl [ABCD]{E}{NSE} @@ -26,4 +26,4 @@ instructions: # O(12) {CDEN} # remove write 0 mark {NSEG} # remove unwraper {A*B*C*} {D*E*} # write 0 - {N*S*E*} # lock all NOT selectors \ No newline at end of file + {N*S*E*U*} # lock all NOT selectors \ No newline at end of file diff --git a/codes/shiftRegister.asm b/codes/shiftRegister.asm index 04e2e3d..a760314 100644 --- a/codes/shiftRegister.asm +++ b/codes/shiftRegister.asm @@ -1,18 +1,57 @@ # -# RULE 110 cellular automaton implementation in DNA|SIMD +# Selected NOT in DNA|SIMD # @autor Lukáš Plevač -# @date 11.21.2023 +# @date 11.27.2023 # define: - 0 {A}[BCD][EF] - 1 {A}{BCD}[EF] + # BIT NOT selector + 0 [ABC][DE][NSE]. + 1 [ABCD]{E}[NSE]. data: - 01 + # Implicit zero + 00110[ABC][DE][NSE] + #01100[ABC][DE][NSE] + #11000[ABC][DE][NSE] + 00000[ABC][DE][NSE] + 11111[ABC][DE][NSE] -instructions: - # need mark for 10 and 01 - {G*E*F*A*} # mark 01 - #{GEFA} # remove mark 01 - #{B*C*D*E*} # write 1 \ No newline at end of file +instructions: # O(34) + {NSEU} # remove all notselectors selector + {D*E*N*} + {DEN} + {E*N*S*E*A*} + {D*E*N*S*E*G*} + {ENSEA} + {E*N*S*E*A*B*} + {ENSEAB} + {E*N*S*E*I*} # bind not selector for 11 + {N*S*E*A*B*C*F*} + {DENSEG} + {NSEABCF} + {D*E*N*S*E*A*B*} + {DENSEAB} + {E*N*S*E*Y*} + {B*C*D*} + {DENSEAB} + {ENSEI} # remove temp not selector for 11 + {N*S*E*U*} # bind not selector for 00 + {ENSEY} + {A*B*C*} # write zero back + {D*E*} # second zero part + # selected not subprogram + {G*D*E*N*} # mark NOT 0 and NOT 1 + {ABCD} # remove unwraped 1 + {GDEN} # remove mark + {C*D*E*N*} # mark write 0 + {CDEN} # remowe mark write 0 (is only posible when is unvraped for second part of zero) + {A*B*C*D*} # write 1 + {ABCD} # remove not writed 1 (is unwraped by mark write 0) + {N*S*E*G*} # unwrap write 0 mark + {CDEN} # remove write 0 mark + {NSEG} # remove unwraper + {A*B*C*} {D*E*} # write 0 + {N*S*E*U*} # lock all NOT selectors + + \ No newline at end of file diff --git a/src/SIMDDNA/assembly.py b/src/SIMDDNA/assembly.py index 2fcfdb8..4f01cf2 100644 --- a/src/SIMDDNA/assembly.py +++ b/src/SIMDDNA/assembly.py @@ -74,6 +74,10 @@ class Assembly: gins = [] for ins in asm: ins = re.sub("\s+" , " ", ins.strip()) # remove whitespaces + com = "" + if len(ins.split("#")) > 1: + com = ins.split("#")[1] + ins = ins.split("#")[0] # remove comments if "instructions:" in ins: @@ -89,9 +93,12 @@ class Assembly: DNAInsArray.append(molecule.parse(self.useMacros(DNAin))) if len(DNAInsArray) > 0: - gins.append(DNAInsArray) + gins.append({ + "ins": DNAInsArray, + "comment": com + }) - return gins + return gins def decode(self, reg): mol = molecule.encode(reg.mol) diff --git a/src/main.py b/src/main.py index 9034b59..11c0d2f 100755 --- a/src/main.py +++ b/src/main.py @@ -10,6 +10,7 @@ parser.add_argument('assembly') parser.add_argument('-s', '--spaceing', default=" ", help='space sentense between ascii char of DNA strands') parser.add_argument('-v', '--verbose', help='show simulation step by step not only final', action='store_true', default=False) parser.add_argument('-d', '--decode', help='use macros to decode final result', action='store_true', default=False) +parser.add_argument('-c', '--comments', help='show comments for instructions', action='store_true', default=False) args = parser.parse_args() @@ -43,7 +44,11 @@ for ins in asm.getInstructions(): print("=================================") print() - for insc in ins: + if args.comments: + print("#%s" % ins["comment"]) + print("") + + for insc in ins["ins"]: insc.rawPrint() print() @@ -52,7 +57,7 @@ for ins in asm.getInstructions(): print() for reg in regs: - reg.instruction(ins) + reg.instruction(ins["ins"]) if args.verbose: reg.asciiShow(spaceing = args.spaceing)