summaryrefslogtreecommitdiff
path: root/py/asmthumb.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-21 13:33:15 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-21 13:33:15 +0100
commite5f8a77db6b7328b9583cbd0fe6ac73535fca1a0 (patch)
treedc781d058bc820f6e9300bfe5ee56629c46f11f2 /py/asmthumb.c
parent764af4b7c585831afa4996c2cf371403330faa35 (diff)
py: Add 'align' and 'data' meta-instructions to inline assembler.
Diffstat (limited to 'py/asmthumb.c')
-rw-r--r--py/asmthumb.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c
index 7037ac518..c178f634d 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -209,6 +209,20 @@ void asm_thumb_label_assign(asm_thumb_t *as, uint label) {
}
}
+void asm_thumb_align(asm_thumb_t* as, uint align) {
+ // TODO fill unused data with NOPs?
+ as->code_offset = (as->code_offset + align - 1) & (~(align - 1));
+}
+
+void asm_thumb_data(asm_thumb_t* as, uint bytesize, uint val) {
+ byte *c = asm_thumb_get_cur_to_write_bytes(as, bytesize);
+ // little endian
+ for (uint i = 0; i < bytesize; i++) {
+ *c++ = val;
+ val >>= 8;
+ }
+}
+
STATIC int get_label_dest(asm_thumb_t *as, uint label) {
assert(label < as->max_num_labels);
return as->label_offsets[label];