Skip to content

Commit e377cd2

Browse files
author
cousdev
committed
Started adding stack package
1 parent 884a63d commit e377cd2

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

asmx/asmx_core/packages/stack.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# packages/stack.py
2+
3+
def expand_push(instruction):
4+
target_reg = instruction["args"][0]
5+
expanded = []
6+
7+
expanded.append("DEC u8")
8+
expanded.append(f"STORER u8 {target_reg}")
9+
10+
11+
def expand_pop(instruction):
12+
target_reg = instruction["args"][0]
13+
expanded = []
14+
15+
expanded.append(f"LOADR {target_reg} u8")
16+
expanded.append("INC u8")
17+
18+
19+
def expand_peek(instruction):
20+
print()
21+
22+
def expand_drop(instruction):
23+
print()
24+
25+
package_registry = {
26+
"namespace": "stack",
27+
"grammar": {
28+
"push": ["register"],
29+
"pop": ["register"],
30+
"peek": ["register"],
31+
"drop": []
32+
},
33+
"macros": {
34+
"push": expand_push,
35+
"pop": expand_pop,
36+
"peek": expand_peek,
37+
"drop": expand_drop
38+
}
39+
}

asmx/asmx_core/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"jeq",
1616
"jgt",
1717
"rand",
18-
"hardcall"
18+
"hardcall",
19+
"loadr",
20+
"storer"
1921
]
2022

2123
from colorama import init, Fore, Style
@@ -46,7 +48,8 @@
4648
"jeq": ["register", "register_or_immediate", "label"],
4749
"jgt": ["register", "register_or_immediate", "label"],
4850
"rand": ["register", "register_or_immediate", "register_or_immediate"],
49-
"hardcall": ["immediate"]
51+
"hardcall": ["immediate"],
52+
"loadr": ["register", "register"]
5053
}
5154

5255
package_namespaces = {}

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = asmx
3-
version = 0.1.2
3+
version = 0.1.3
44
description = ASMX - A macro assembler and virtual machine platform running on Scratch
55
long_description = file: README.md
66
long_description_content_type = text/markdown

0 commit comments

Comments
 (0)