master
Reese 2 years ago
parent 50bd257979
commit 018f1f4893

1
.gitignore vendored

@ -0,0 +1 @@

@ -8,5 +8,76 @@ if len(sys.argv) < 2:
print("Add arguments!")
quit()
markers = {}
file = open(sys.argv[1])
print(file.readlines()[1])
fullfile = file.readlines()
file.close()
output = open(sys.argv[1].strip('.ra') + '.rc', 'w+')
line = 1
registers = {
#normal
'acc': '01000000',
'a': '00100000',
'b': '01100000',
'c': '00010000',
#special
'zero': '00000000',
'full': '00000001',
'dbgo': '00000010',
'dbgi': '00000011',
'pgcr': '00000100'}
for i in fullfile:
temp = None
binified = None
line = line + 1
instruction = i.strip()
instruction = instruction.lower().split(' ')
print(instruction)
if instruction[0][0] == '!':
markers[instruction[0][1:].strip('\n')] = line
line = line - 1
print("marker")
elif instruction[0] == 'nul':
print("nul")
output.write('00000000\n')
elif instruction[0] == 'mov':
print("mov")
temp = '010000ab;'
if registers.get(instruction[1], 'fail') != 'fail':
temp = temp + registers.get(instruction[1]) + ';'
temp = temp.replace('a', '1')
else:
binified = bin(int(instruction[1]))[2:][::-1]
temp = temp + binified + ';'
temp = temp.replace('a', '0')
if registers.get(instruction[2], 'fail') != 'fail':
temp = temp + registers.get(instruction[2])
temp = temp.replace('b', '1') + '\n'
output.write(str(temp))
else:
binified = bin(int(instruction[2]))[2:][::-1]
temp = temp + binified
temp = temp.replace('b', '0') + '\n'
output.write(str(temp))
elif instruction[0] == 'add':
print("add")
else:
print("Error!")
print("Line: " + str(line))
#quit()
print(markers)

@ -1,8 +1,8 @@
MOV 1 A
MOV 1 A
MOV 1 B
MOV -100 C
MOV A DBGO
lop:
!lop:
ADD A B
MOV A B
MOV ACC A

@ -0,0 +1,5 @@
NUL
MOV 100 B
MOV 100 100
MOV 1 A
MOV 5 B

@ -0,0 +1,5 @@
00000000
01000001;0010011;01100000
01000000;0010011;0010011
01000001;1;00100000
01000001;101;01100000
Loading…
Cancel
Save