aboutsummaryrefslogtreecommitdiff
path: root/py/asmthumb.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-03-02 17:51:32 +0000
committerDamien George <damien.p.george@gmail.com>2015-03-02 17:51:32 +0000
commit67c5f89af539e0778155dcd35b58c32af64debec (patch)
tree2ec47ad6aed911fff82e7fd877cc0b13f7df71ab /py/asmthumb.c
parent24ffb8e8762c2f14fe109edbc42401285eb8247b (diff)
py: In inline assembler, fix branch out-of-range error reporting.
Should only give an error on the last pass of the assembler, since that's when we are certain about the branch size.
Diffstat (limited to 'py/asmthumb.c')
-rw-r--r--py/asmthumb.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c
index ad6700088..5bf2d80bb 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -297,12 +297,8 @@ bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) {
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_FIT12(rel)) {
- asm_thumb_op16(as, OP_B_N(rel));
- return true;
- } else {
- return false;
- }
+ asm_thumb_op16(as, OP_B_N(rel));
+ return as->pass != ASM_THUMB_PASS_EMIT || SIGNED_FIT12(rel);
}
#define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff))
@@ -316,12 +312,8 @@ bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide) {
mp_int_t rel = dest - as->code_offset;
rel -= 4; // account for instruction prefetch, PC is 4 bytes ahead of this instruction
if (!wide) {
- if (SIGNED_FIT9(rel)) {
- asm_thumb_op16(as, OP_BCC_N(cond, rel));
- return true;
- } else {
- return false;
- }
+ asm_thumb_op16(as, OP_BCC_N(cond, rel));
+ return as->pass != ASM_THUMB_PASS_EMIT || SIGNED_FIT9(rel);
} else {
asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel));
return true;
@@ -335,12 +327,8 @@ bool asm_thumb_bl_label(asm_thumb_t *as, uint label) {
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_FIT23(rel)) {
- asm_thumb_op32(as, OP_BL_HI(rel), OP_BL_LO(rel));
- return true;
- } else {
- return false;
- }
+ asm_thumb_op32(as, OP_BL_HI(rel), OP_BL_LO(rel));
+ return as->pass != ASM_THUMB_PASS_EMIT || SIGNED_FIT23(rel);
}
void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32) {