-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatalang.py
More file actions
45 lines (43 loc) · 1.08 KB
/
datalang.py
File metadata and controls
45 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
mem = [0]*1025
def interpret(arg):
for i in arg:
a = i.split()
if a[0].startswith("0x"):
mem[int(a[0], 16)]=int(a[1], 16)
else:
print("invalid instruction")
break
outstart = 1024-256
while outstart<=1024:
if mem[outstart]!=0:
print(chr(mem[outstart]), end="")
outstart += 1
ilist = []
while True:
a = input("> ")
if a=="list":
print("\n".join(ilist))
elif a=="run":
interpret(ilist)
elif a=="poplist":
ilist.pop()
elif a=="clearlist":
ilist = []
elif a=="":
continue
elif a.split()[0]=="c2h":
if a.split()[1]=="space":
print(hex(ord(" ")))
else:
print(hex(ord(a.split()[1][0])))
elif a=="mem":
integer = 0
while integer < len(mem):
print(hex(mem[integer]), end=" ")
if integer % 10 == 0:
print(hex(integer))
integer += 1
print(hex(integer))
else:
if a.startswith("0x"):
ilist.append(a)