Skip to content

Commit

Permalink
Minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Menotti committed Apr 29, 2021
1 parent 83149c0 commit e5b5733
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.pyc
*.hack
*.bin
21 changes: 21 additions & 0 deletions assembler/fibo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/python

a, b, c = 0, 1, 0

print "a b c (fibo ->)"
print a, b, c

for i in range(12):
c = a + b
a = b
b = c
print a, b, c

print "a b c (<- ribo)"

for i in range(12):
c = b - a
b = a
a = c
print a, b, c

16 changes: 16 additions & 0 deletions assembler/ribo.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Fibonacci sequence de-generator

loop: # infinite...
LOAD b
SUB a
STORE c
LOAD a
STORE b
LOAD c
STORE a
JUMP loop

# variables
.a 144
.b 233
.c 0
12 changes: 6 additions & 6 deletions assembler/tables.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from collections import OrderedDict

inst_table = {
"ADD" : "0101",
"SUB" : "0110",
"LOAD" : "0100",
"STORE" : "0011",
"JUMP" : "1"
}

space_table = OrderedDict()
space_table["code"] = 128
space_table["unused"] = 112
space_table["data"] = 16
space_table = {
"code" : 128,
"unused" : 112,
"data" : 16
}

0 comments on commit e5b5733

Please sign in to comment.