Skip to content

Commit ab65e38

Browse files
implement .set directive (only ints as expr for now), fixes #14
1 parent 93ad8d7 commit ab65e38

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

demo.S

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
.text
44

5+
.set constant42, 42
6+
57
textstart: ld r0, r1, 0 # a comment!
68
st r0, r1, 0 // another comment!
79
add r0, r1, r2
@@ -19,6 +21,7 @@ textstart: ld r0, r1, 0 # a comment!
1921
move r0, r1
2022
move r0, 42
2123
move r0, textstart # moves abs addr of textstart to r0
24+
move r0, constant42
2225
stage_rst
2326
stage_inc 42
2427
stage_dec 23

esp32_ulp/assemble.py

+4
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ def d_skip(self, amount, fill=None):
215215

216216
d_space = d_skip
217217

218+
def d_set(self, symbol, expr):
219+
value = int(expr) # TODO: support more than just integers
220+
self.symbols.set_sym(symbol, ABS, None, value)
221+
218222
def append_data(self, wordlen, args):
219223
data = [int(arg).to_bytes(wordlen, 'little') for arg in args]
220224
self.append_section(b''.join(data))

tests/compat/symbols.S

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
.text
22

3+
.set constant42, 42
4+
35
start: move r0, data0
46
move r1, data1
7+
move r2, constant42
58

69
# count from 0 .. 42 in stage register
710
stage_rst

0 commit comments

Comments
 (0)