Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKilobyte authored Jun 2, 2023
1 parent 2d1ca57 commit 9b77a34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Binary file modified omicron.exe
Binary file not shown.
9 changes: 6 additions & 3 deletions omicron.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def mem(instruction):
elif instruction == 'tan':
memory[pointer] = math.tan(memory[pointer])
elif instruction == 'log':
memory[pointer] = math.log(memory[pointer], mem(program[i+1]))
if mem(program[i+1]) > 1: memory[pointer] = math.log(memory[pointer], mem(program[i+1]))
else: error("Log base must be 2 or greater")
i += 1
elif instruction == 'abs': memory[pointer] = abs(memory[pointer])
elif instruction == 'not': memory[pointer] = int(not memory[pointer])
Expand Down Expand Up @@ -118,8 +119,10 @@ def mem(instruction):
stdin = input()
memory[pointer] = ord(stdin[0]) if len(stdin) > 0 else 0
elif instruction == 'read':
with open(program[i+1], 'rb') as f:
memory[pointer] = f.read()[mem(program[i+2])]
try:
with open(program[i+1], 'rb') as f: memory[pointer] = f.read()[mem(program[i+2])]
except FileNotFoundError:
error("File not found: %s"%program[i+1])
i += 2
elif instruction == 'size':
with open(program[i+1], 'rb') as f: memory[pointer] = len(f.read())
Expand Down

0 comments on commit 9b77a34

Please sign in to comment.