0 push adr 1 pop adr 2 jmp adr 3 jmp0 adr; pops from stack, if it's 0, then it jumps 4 halt 5 add adr; push(pop+ram[adr]) 6 sub adr 7 not 8 or adr 9 and adr 10 xor adr 11 hardware port; pops stack and sends request to specified hardware 12 exarg; extends the argument for the next non-exarg instruction (moar ram) please note that the output for jump commands has been modified to say which instruction will be executed next press ` to paste a space-seperated list. press space to hide/show debug monitors
#COPY ME #write in file "toassemble", navigate to the folder with both files in and then run the python file #then, import the output.txt file into the boot list (not ram or it'll be wiped when you start the file) opcodes = { "push":0, "pop":1, "jmp":2, "jmp0":3, "halt":4, "add":5, "sub":6, "not":7, "or":8, "and":9, "xor":10, "hard":11 } e=[] last = 0 with open("toassemble") as tasmf: tasm = tasmf.readlines() for i in tasm: for j in i.split(" "): if last == 4: e.append(0) continue if (last == 2 or last == 3) and len(e)%2 == 1: try: e.append(int(j)*2-1) last = int(j) except: e.append(opcodes.get(j)*2-1) last = opcodes.get(j) else: try: e.append(int(j)) last = int(j) except: e.append(opcodes.get(j)) last = opcodes.get(j) if last == 4 and len(e)%2 == 1: e.append(0) out ="" print(e) for i in e: out = out+str(i)+"\n" with open("out.txt","w") as outf: outf.write(out)