What Is This 'OLOC'
OLOC (One line One command)
The programming language for the Saturn NX processor.
Roughly speaking, it's just an assembler,
but it's more similar to modern programming languages.
Emulator Saturn NX built in, but without external devices support (in development)
Compiled file can be saved into program with or without comments (in working out save in binary form)
Report all errors to the compiler here:
https://github.com/asafonnikov/OLOC/issues
Download the emulator here:
https://github.com/asafonnikov/OLOC
Or in the last section source in Python light version (without debug messages and emulator)
Syntax
Assignments:
<R/r/D/d><0-F> = <000-255>.
Copying:
<R/r/D/d><0-F> = <R/r/D/d><0-F>.
Calculation:
<R/r/D/d><0-F> <&&-%%> <R/r/D/d><0-F>
Conditions:
&& - AND
|| - OR
^^ - XOR
!! - NOT
!& - NAND
!| - NOR
!^ - XNOR
++ - ADD
-- SUB
U* - MUL UP
L* - MUL LOW
>> - SHR
<< - SHL
>< - ASHL
%% - BIT INDEXER
Transitions:
IF <R/r/D/d><0-F> <== 0->= 0> <+/-><R/r/D/d><0-F>
OR
IF <ALWAYS -NEVER > <+/-><R/r/D/d><0-F>
Conditions:
NEVER
== 0
<< 0
<= 0
ALWAYS
!= 0
>> 0
>= 0
Note 1: Conditions can only be with 0
Note 2: ALWAYS condition has a space at the end, NEVER condition has 2
Examples Of Programs
The "Saturn NX OLOC" circuit is required for the examples to work correctly
R1 == 1 R2 == 4 D6 = R0 D7 = R0 R0 ++ R1 NOP IF ALWAYS -R2Try to understand:
What it does:
Counter
How it works:
Adds up register 0 and 1 (where 1 was written before) and saves the value to the address register and RAM
A more complex program:
D6 = 255 R4 = 035 R3 = 003 R2 = 001 R1 = 048 R0 = 000 R0 = D8 IF R0 != 0 -R2 R0 -- R1 R0 U* R3 R0 ++ R2 IF ALWAYS +R0 NOP D7 = 063 IF ALWAYS -R4 NOP D7 = 006 IF ALWAYS -R4 NOP D7 = 091 IF ALWAYS -R4 NOP D7 = 079 IF ALWAYS -R4 NOP D7 = 102 IF ALWAYS -R4 NOP D7 = 109 IF ALWAYS -R4 NOP D7 = 125 IF ALWAYS -R4 NOP D7 = 007 IF ALWAYS -R4 NOP D7 = 127 IF ALWAYS -R4 NOP D7 = 111 IF ALWAYS -R4What it does:
When you press the 0 button, it outputs 0, 1 1, 5 5, etc.
How it works:
It waits for input from keyboard, then subtracts 48 from received number (0 in ascii), multiplies by 3 and adds 1, goes over received number, puts number on display and goes back to beginning
A more complicated program:
Lightened Version
def htd(val): if val == "0" or val == "1" or val == "2" or val == "3" or val == "4" or val == "5" or val == "6" or val == "7" or val == "8" or val == "9": return(int(val)) elif val == "a" or val == "A": return(10) elif val == "b" or val == "B": return(11) elif val == "c" or val == "C": return(12) elif val == "d" or val == "D": return(13) elif val == "e" or val == "E": return(14) elif val == "f" or val == "F": return(15) else: return(-1) def chkDev(inp): if inp == "r" or inp == "R" or inp == "d" or inp == "D": return(True) else: return(False) def dth(val): if val < 10: return(str(val)) elif val == 10: return("A") elif val == 11: return("B") elif val == 12: return("C") elif val == 13: return("D") elif val == 14: return("E") elif val == 15: return("F") def ifCond(symb, couNum, reg0, reg1): if htd(reg0) == -1: reg0 = "0" if symb == "+": return("C" + couNum + reg0 + reg1) elif symb == "-": return("D" + couNum + reg0 + reg1) else: input() exit("Syntax error") time.sleep(0.1) prom = [] helpAdress = "https://github.com/asafonnikov/OLOC" cali = [] print("OLOC v0.5 compilator for architecture Saturn NX, powered by SNXEE v0.9") comFile = open(input("File path: "), 'r') f = comFile.readlines() comFile.close() for _ in range(len(f)): if len(f[_]) < 2: pass elif f[_][0] == "#": pass elif f[_][0] + f[_][1] + f[_][2] == "nop" or f[_][0] + f[_][1] + f[_][2] == "Nop" or f[_][0] + f[_][1] + f[_][2] == "NOP": prom.append("c000") cali.append(_) elif chkDev(f[_][0]) and htd(f[_][1]) != -1 and f[_][3] == "=" and chkDev(f[_][5]) and htd(f[_][6]) != -1: prom.append("0" + str(f[_][1]) + "0" + str(f[_][6])) cali.append(_) elif chkDev(f[_][0]) and htd(f[_][1]) != -1 and f[_][3] == "=": prom.append("8" + str(f[_][1]) + str(dth(int(int(f[_][5] + f[_][6] + f[_][7]) / 16))) + str(dth(int(f[_][5] + f[_][6] + f[_][7]) & 15))) cali.append(_) elif chkDev(f[_][0]) and htd(f[_][1]) != -1 and chkDev(f[_][6]) and htd(f[_][7]) != -1: if f[_][3] + f[_][4] == "&&": prom.append("4" + "0" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "||": prom.append("4" + "1" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "^^": prom.append("4" + "2" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "!!": prom.append("4" + "3" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "!&": prom.append("4" + "4" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "!|": prom.append("4" + "5" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "!^": prom.append("4" + "6" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "++": prom.append("4" + "8" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "--": prom.append("4" + "9" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "U*" or f[_][3] + f[_][4] == "u*": prom.append("4" + "A" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "L*" or f[_][3] + f[_][4] == "l*": prom.append("4" + "B" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == ">>": prom.append("4" + "C" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "<<": prom.append("4" + "D" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "><": prom.append("4" + "E" + str(f[_][1]) + str(f[_][7])) elif f[_][3] + f[_][4] == "%%": prom.append("4" + "F" + str(f[_][1]) + str(f[_][7])) else: input("Press enter to continue") exit("Invaild operation on line " + str(_ + 1)) continue cali.append(_) elif (f[_][0] + f[_][1] == "if" or f[_][0] + f[_][1] == "If" or f[_][0] + f[_][1] == "IF") and chkDev(f[_][12]) and htd(f[_][13]) != -1: if f[_][6] + f[_][7] + f[_][8] + f[_][9] == "ER " or f[_][6] + f[_][7] + f[_][8] + f[_][9] == "er ": prom.append(ifCond(f[_][11], "0", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == "== 0": prom.append(ifCond(f[_][11], "1", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == "<= 0": prom.append(ifCond(f[_][11], "2", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == "<< 0": prom.append(ifCond(f[_][11], "3", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == "AYS " or f[_][6] + f[_][7] + f[_][8] + f[_][9] == "ays ": prom.append(ifCond(f[_][11], "4", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == "!= 0": prom.append(ifCond(f[_][11], "5", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == ">> 0": prom.append(ifCond(f[_][11], "6", f[_][4], f[_][13])) elif f[_][6] + f[_][7] + f[_][8] + f[_][9] == ">= 0": prom.append(ifCond(f[_][11], "7", f[_][4], f[_][13])) else: print("Invaild condition on line", _ + 1) input("Press enter to continue") exit("Invaild condition on line " + str(_ + 1)) continue cali.append(_) else: print("Invaild syntax on line", _ + 1) input("Press enter to continue") exit("Invaild syntax on line " + str(_ + 1)) continue if len(prom) != 0 and len(prom[len(prom) - 1]) != 4: print("Unkown error in compilator, please send line", _ + 1, "from your prgramm to", helpAdress) input("Press enter to continue") exit("Unkown error in compilator") elif len(prom) != 0: for _2 in range(4): if htd(prom[len(prom) - 1][_2]) == -1: print("Unkown error in compilator, please send line", _ + 1, "from your prgramm to", helpAdress) input("Press enter to continue") exit("Unkown error in compilator") print("Compile complete!") while True: srom = [] irom = "" print("0 - Show machine code") print("2 - Save") print("q - Quit") tmp0 = input() if tmp0 == "0": print(prom) elif tmp0 == "2": print("1 - Save in assembly format") print("2 - Save in assembly foramt with commentaries") tmp0 = input() srom = [] if tmp0 == "1": for _ in range(len(prom)): srom.append("0x" + prom[_][0] + prom[_][1] + prom[_][2] + prom[_][3]) elif tmp0 == "2": for _ in range(len(prom)): srom.append("0x" + prom[_][0] + prom[_][1] + prom[_][2] + prom[_][3] + " # " + f[cali[_]]) for _ in range(len(srom)): irom += srom[_] if tmp0 == "1": irom += "\n" buildfile = open(input('Save file name: '), 'w', encoding="utf-8") buildfile.write(irom) buildfile.close() elif tmp0 == "q": exit()
Source: https://steamcommunity.com/sharedfiles/filedetails/?id=2971197933
More Turing Complete guilds
- All Guilds
- Turing Complete Guide 202
- Turing Complete: Basic Logic-Manual
- Robot Racing
- Turing Complete: Basic Logic-Solution
- Turing Complete: CPU Architecture-Solution
- Turing Complete: Arithmetic and Memory-Solution
- The 6502 Microprocessor
- Turing Complete: All-level walkthrough
- Turing Complete Guide 157
- / Turing Complete