Skip to content

Commit

Permalink
Issue #2 and issue ucu-computer-science#7: now comments right after c…
Browse files Browse the repository at this point in the history
…ommands is possible, RISC name was taken away from Stach and Accumulator isas
  • Loading branch information
MykhailoBronytskyi committed Nov 1, 2022
1 parent bdfa48b commit f320ee6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/INSTRUCTION_SET2.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ being saved into the first operand:

## Instructions for each architecture

| RISC STACK | RISC ACCUMULATOR | RISC REGISTER | CISC REGISTER |
| STACK | ACCUMULATOR | REGISTER | CISC REGISTER |
|------------|------------------|---------------|---------------|
| **Registers** ||||
| ```TOS```; ```CF```; ```SP```; ```IP``` | ```ACC```; ```IR```; ```FR```; ```SP```; ```IP``` | ```R00: R00H, R00L```; ```R01: R01H, R01L```; ```R02: R02H, R02L```; ```R03: R03H, R03L```; ```LR```; ```FR```; ```SP```; ```IP``` | ```R00: R00H, R00L```; ```R01: R01H, R01L```; ```R02: R02H, R02L```; ```R03: R03H, R03L```; ```FR```; ```BP``; ```SP```; ```IP``` |
Expand Down
4 changes: 2 additions & 2 deletions docs/help.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"risc1": [
"Instruction Set for RISC-Stack ISA",
"Instruction Set for Stack ISA",
{
"name": "load",
"examples": [
Expand Down Expand Up @@ -227,7 +227,7 @@
}
],
"risc2": [
"Instruction Set for RISC-Accumulator ISA",
"Instruction Set for Accumulator ISA",
{
"name": "load",
"examples": [
Expand Down
18 changes: 16 additions & 2 deletions modules/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def translate(self, text):

return binary_code

def preprocess(self, text):
def preprocess(self, text : str):
"""
Preprocesses the assembly code, finds any directives and collects the needed info on them
Expand All @@ -206,7 +206,21 @@ def preprocess(self, text):
self.jump_labels = dict()
self.mov_labels = dict()

for line in text.split("\n"):

text = text.split("\n")
text_no_comments = []

for line in text:

line_no_comment = line.split("#", 1)[0].strip()
if line_no_comment:

text_no_comments.append(line_no_comment)

# text = "\n".join(text_no_comments)


for line in text_no_comments:
line = line.rstrip(" ")

# Check if its an empty line or a comment line, skip it if yes
Expand Down
3 changes: 2 additions & 1 deletion modules/demos/risc3/helloworld.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# These next instructions load ASCII encodings of characters in "Hello world!" into registers
# and then push them onto the stack, backwards, so that when the values are popped from the stack,
# we can output the values in a normal way
mov_low %R00, $33
mov_low %R00, $33 # mov_low %R00, $33
push %R00
mov_low %R00, $100
push %R00
Expand Down

0 comments on commit f320ee6

Please sign in to comment.