-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Empty file.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
constant FeM 5 | ||
label start | ||
# comment | ||
sio 1 0 10 | ||
addi 1 FeM | ||
|
||
#blablabla | ||
lio 1 0 9 | ||
jmp start |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import instructions | ||
import os | ||
|
||
def decode(word:str): | ||
word = word.replace("\n", "") | ||
dec_text :list = (word.split(" ")) | ||
return(dec_text) | ||
|
||
def is_int(s:str): | ||
try: | ||
int(s) | ||
return(True) | ||
except(ValueError): | ||
pass | ||
return(False) | ||
|
||
|
||
file_path: str = "file.code" | ||
|
||
jump_or_branch :tuple = ("jmp", "b", "jeq", | ||
"beq", "jneq", "bneq", "jl", "bl", "jleq", | ||
"bleq", "jg", "bg", "jgeq", "bgeq", "jeqi", | ||
"beqi", "jneqi", "bneqi", "jli", "bli", | ||
"jleqi", "bleqi", "jgi", "bgi", "jgeqi", "bgeqi") | ||
|
||
with open(file_path, 'r') as input: | ||
with open('a.bin', 'w+b') as output: | ||
EOF :bool = False | ||
line_num :int = 0 | ||
constants :dict = {} | ||
labels :dict = {} | ||
text :str = "" | ||
dec_text :list = [] | ||
|
||
while(EOF == False): | ||
|
||
text = input.readline() | ||
if (text == ""): | ||
EOF = True | ||
elif (text[0] == "\n" or "#" in text): | ||
continue | ||
else: | ||
dec_text = decode(text) | ||
if (dec_text[0] == "constant" or dec_text[0] == "const"): | ||
constants[dec_text[1]] = dec_text[2] | ||
elif (dec_text[0] == "label"): | ||
labels[dec_text[1]] = line_num | ||
else: | ||
#print(str(dec_text) + str(line_num)) | ||
line_num += 1 | ||
|
||
l :bool = False | ||
line :list = [] | ||
for i in dec_text: | ||
|
||
if (l == True): | ||
l = False | ||
line.append(i) | ||
elif (i in jump_or_branch): | ||
l = True | ||
line.append(i) | ||
else: | ||
line.append(i) | ||
print(line) | ||
|
||
print("constants = " + str(constants)) | ||
print("labels = " + str(labels)) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# *A Guide to The Computers Assembly* | ||
|
||
## Constants | ||
Constants are variables and defined at the start of a file with | ||
`Const: | ||
var_A = 52 | ||
var_B = 42`. | ||
Where "var_A" and "var_B" are the variable names. | ||
|
||
## Labels | ||
Lebels are defined with `label`. | ||
It labels the next line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters