4242#define SIGNED_FIT12 (x ) (((x) & 0xfffff800) == 0) || (((x) & 0xfffff800) == 0xfffff800)
4343
4444struct _asm_thumb_t {
45- uint pass ;
46- uint code_offset ;
47- uint code_size ;
45+ mp_uint_t pass ;
46+ mp_uint_t code_offset ;
47+ mp_uint_t code_size ;
4848 byte * code_base ;
4949 byte dummy_data [4 ];
5050
51- uint max_num_labels ;
52- int * label_offsets ;
53- int num_locals ;
54- uint push_reglist ;
55- uint stack_adjust ;
51+ mp_uint_t max_num_labels ;
52+ mp_uint_t * label_offsets ;
53+ mp_uint_t push_reglist ;
54+ mp_uint_t stack_adjust ;
5655};
5756
5857asm_thumb_t * asm_thumb_new (uint max_num_labels ) {
5958 asm_thumb_t * as ;
6059
6160 as = m_new0 (asm_thumb_t , 1 );
6261 as -> max_num_labels = max_num_labels ;
63- as -> label_offsets = m_new (int , max_num_labels );
62+ as -> label_offsets = m_new (mp_uint_t , max_num_labels );
6463
6564 return as ;
6665}
@@ -88,7 +87,7 @@ void asm_thumb_start_pass(asm_thumb_t *as, uint pass) {
8887 as -> pass = pass ;
8988 as -> code_offset = 0 ;
9089 if (pass == ASM_THUMB_PASS_COMPUTE ) {
91- memset (as -> label_offsets , -1 , as -> max_num_labels * sizeof (int ));
90+ memset (as -> label_offsets , -1 , as -> max_num_labels * sizeof (mp_uint_t ));
9291 }
9392}
9493
@@ -169,7 +168,7 @@ STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
169168
170169// locals:
171170// - stored on the stack in ascending order
172- // - numbered 0 through as-> num_locals-1
171+ // - numbered 0 through num_locals-1
173172// - SP points to first local
174173//
175174// | SP
@@ -222,7 +221,6 @@ void asm_thumb_entry(asm_thumb_t *as, int num_locals) {
222221 }
223222 as -> push_reglist = reglist ;
224223 as -> stack_adjust = stack_adjust ;
225- as -> num_locals = num_locals ;
226224}
227225
228226void asm_thumb_exit (asm_thumb_t * as ) {
@@ -262,7 +260,7 @@ void asm_thumb_data(asm_thumb_t* as, uint bytesize, uint val) {
262260 }
263261}
264262
265- STATIC int get_label_dest (asm_thumb_t * as , uint label ) {
263+ STATIC mp_uint_t get_label_dest (asm_thumb_t * as , uint label ) {
266264 assert (label < as -> max_num_labels );
267265 return as -> label_offsets [label ];
268266}
@@ -348,15 +346,11 @@ void asm_thumb_movt_reg_i16(asm_thumb_t *as, uint reg_dest, int i16_src) {
348346 asm_thumb_mov_reg_i16 (as , OP_MOVT , reg_dest , i16_src );
349347}
350348
351- void asm_thumb_ite_ge (asm_thumb_t * as ) {
352- asm_thumb_op16 (as , 0xbfac );
353- }
354-
355349#define OP_B_N (byte_offset ) (0xe000 | (((byte_offset) >> 1) & 0x07ff))
356350
357351void asm_thumb_b_n (asm_thumb_t * as , uint label ) {
358- int dest = get_label_dest (as , label );
359- int rel = dest - as -> code_offset ;
352+ mp_uint_t dest = get_label_dest (as , label );
353+ mp_int_t rel = dest - as -> code_offset ;
360354 rel -= 4 ; // account for instruction prefetch, PC is 4 bytes ahead of this instruction
361355 if (SIGNED_FIT12 (rel )) {
362356 asm_thumb_op16 (as , OP_B_N (rel ));
@@ -368,8 +362,8 @@ void asm_thumb_b_n(asm_thumb_t *as, uint label) {
368362#define OP_BCC_N (cond , byte_offset ) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff))
369363
370364void asm_thumb_bcc_n (asm_thumb_t * as , int cond , uint label ) {
371- int dest = get_label_dest (as , label );
372- int rel = dest - as -> code_offset ;
365+ mp_uint_t dest = get_label_dest (as , label );
366+ mp_int_t rel = dest - as -> code_offset ;
373367 rel -= 4 ; // account for instruction prefetch, PC is 4 bytes ahead of this instruction
374368 if (SIGNED_FIT9 (rel )) {
375369 asm_thumb_op16 (as , OP_BCC_N (cond , rel ));
@@ -442,8 +436,8 @@ void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num)
442436#define OP_BW_LO (byte_offset ) (0xb800 | (((byte_offset) >> 1) & 0x07ff))
443437
444438void asm_thumb_b_label (asm_thumb_t * as , uint label ) {
445- int dest = get_label_dest (as , label );
446- int rel = dest - as -> code_offset ;
439+ mp_uint_t dest = get_label_dest (as , label );
440+ mp_int_t rel = dest - as -> code_offset ;
447441 rel -= 4 ; // account for instruction prefetch, PC is 4 bytes ahead of this instruction
448442 if (dest >= 0 && rel <= -4 ) {
449443 // is a backwards jump, so we know the size of the jump on the first pass
@@ -465,8 +459,8 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label) {
465459#define OP_BCC_W_LO (byte_offset ) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff))
466460
467461void asm_thumb_bcc_label (asm_thumb_t * as , int cond , uint label ) {
468- int dest = get_label_dest (as , label );
469- int rel = dest - as -> code_offset ;
462+ mp_uint_t dest = get_label_dest (as , label );
463+ mp_int_t rel = dest - as -> code_offset ;
470464 rel -= 4 ; // account for instruction prefetch, PC is 4 bytes ahead of this instruction
471465 if (dest >= 0 && rel <= -4 ) {
472466 // is a backwards jump, so we know the size of the jump on the first pass
0 commit comments