@@ -307,15 +307,24 @@ bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) {
307307
308308#define OP_BCC_N (cond , byte_offset ) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff))
309309
310- bool asm_thumb_bcc_n_label (asm_thumb_t * as , int cond , uint label ) {
310+ // all these bit arithmetics need coverage testing!
311+ #define OP_BCC_W_HI (cond , byte_offset ) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f))
312+ #define OP_BCC_W_LO (byte_offset ) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff))
313+
314+ bool asm_thumb_bcc_nw_label (asm_thumb_t * as , int cond , uint label , bool wide ) {
311315 mp_uint_t dest = get_label_dest (as , label );
312316 mp_int_t rel = dest - as -> code_offset ;
313317 rel -= 4 ; // account for instruction prefetch, PC is 4 bytes ahead of this instruction
314- if (SIGNED_FIT9 (rel )) {
315- asm_thumb_op16 (as , OP_BCC_N (cond , rel ));
316- return true;
318+ if (!wide ) {
319+ if (SIGNED_FIT9 (rel )) {
320+ asm_thumb_op16 (as , OP_BCC_N (cond , rel ));
321+ return true;
322+ } else {
323+ return false;
324+ }
317325 } else {
318- return false;
326+ asm_thumb_op32 (as , OP_BCC_W_HI (cond , rel ), OP_BCC_W_LO (rel ));
327+ return true;
319328 }
320329}
321330
@@ -416,10 +425,6 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label) {
416425 }
417426}
418427
419- // all these bit arithmetics need coverage testing!
420- #define OP_BCC_W_HI (cond , byte_offset ) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f))
421- #define OP_BCC_W_LO (byte_offset ) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff))
422-
423428void asm_thumb_bcc_label (asm_thumb_t * as , int cond , uint label ) {
424429 mp_uint_t dest = get_label_dest (as , label );
425430 mp_int_t rel = dest - as -> code_offset ;
0 commit comments