diff options
author | Damien George <damien.p.george@gmail.com> | 2015-03-02 14:29:52 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-03-02 14:29:52 +0000 |
commit | 9f142f0c8411d422f689c9cafdf890d7dc599da8 (patch) | |
tree | b7d8d4c740ac46e27af8bd168a7b45e9611c937b /py/asmthumb.c | |
parent | 565da3f569afa5299ed8dd09e740620c2a3e8e6f (diff) |
py: For inline assembler, add bcc_n and bcc_w ops.
Addresses issue #1143.
Diffstat (limited to 'py/asmthumb.c')
-rw-r--r-- | py/asmthumb.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c index d5452ff6f..ad6700088 100644 --- a/py/asmthumb.c +++ b/py/asmthumb.c @@ -307,15 +307,24 @@ bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) { #define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff)) -bool asm_thumb_bcc_n_label(asm_thumb_t *as, int cond, uint label) { +// all these bit arithmetics need coverage testing! +#define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f)) +#define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff)) + +bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide) { mp_uint_t dest = get_label_dest(as, label); mp_int_t rel = dest - as->code_offset; rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction - if (SIGNED_FIT9(rel)) { - asm_thumb_op16(as, OP_BCC_N(cond, rel)); - return true; + if (!wide) { + if (SIGNED_FIT9(rel)) { + asm_thumb_op16(as, OP_BCC_N(cond, rel)); + return true; + } else { + return false; + } } else { - return false; + asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel)); + return true; } } @@ -416,10 +425,6 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label) { } } -// all these bit arithmetics need coverage testing! -#define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f)) -#define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff)) - void asm_thumb_bcc_label(asm_thumb_t *as, int cond, uint label) { mp_uint_t dest = get_label_dest(as, label); mp_int_t rel = dest - as->code_offset; |