34 #if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB 39 #define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0) 40 #define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0) 41 #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) 42 #define SIGNED_FIT9(x) (((x) & 0xffffff00) == 0) || (((x) & 0xffffff00) == 0xffffff00) 43 #define SIGNED_FIT12(x) (((x) & 0xfffff800) == 0) || (((x) & 0xfffff800) == 0xfffff800) 44 #define SIGNED_FIT23(x) (((x) & 0xffc00000) == 0) || (((x) & 0xffc00000) == 0xffc00000) 46 static inline byte *asm_thumb_get_cur_to_write_bytes(
asm_thumb_t *as,
int n) {
54 #if defined(MCU_SERIES_F7) 59 SCB_InvalidateICache();
87 #define OP_PUSH_RLIST(rlolist) (0xb400 | (rlolist)) 88 #define OP_PUSH_RLIST_LR(rlolist) (0xb400 | 0x0100 | (rlolist)) 89 #define OP_POP_RLIST(rlolist) (0xbc00 | (rlolist)) 90 #define OP_POP_RLIST_PC(rlolist) (0xbc00 | 0x0100 | (rlolist)) 92 #define OP_ADD_SP(num_words) (0xb000 | (num_words)) 93 #define OP_SUB_SP(num_words) (0xb080 | (num_words)) 114 if (num_locals < 0) {
118 switch (num_locals) {
141 stack_adjust = ((num_locals - 3) + 1) & (~1);
145 if (stack_adjust > 0) {
160 assert(label < as->base.max_num_labels);
165 byte *
c = asm_thumb_get_cur_to_write_bytes(as, 2);
174 byte *
c = asm_thumb_get_cur_to_write_bytes(as, 4);
184 #define OP_FORMAT_4(op, rlo_dest, rlo_src) ((op) | ((rlo_src) << 3) | (rlo_dest)) 195 op_lo = reg_src << 3;
197 op_lo = 0x40 | ((reg_src - 8) << 3);
202 op_lo |= 0x80 | (reg_dest - 8);
212 asm_thumb_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), ((i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff));
215 #define OP_B_N(byte_offset) (0xe000 | (((byte_offset) >> 1) & 0x07ff)) 218 mp_uint_t dest = get_label_dest(as, label);
225 #define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff)) 228 #define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f)) 229 #define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff)) 232 mp_uint_t dest = get_label_dest(as, label);
244 #define OP_BL_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff)) 245 #define OP_BL_LO(byte_offset) (0xf800 | (((byte_offset) >> 1) & 0x07ff)) 248 mp_uint_t dest = get_label_dest(as, label);
264 if (reg_dest < 8 && UNSIGNED_FIT8(i32)) {
265 asm_thumb_mov_rlo_i8(as, reg_dest, i32);
266 }
else if (UNSIGNED_FIT16(i32)) {
288 #define OP_STR_TO_SP_OFFSET(rlo_dest, word_offset) (0x9000 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) 289 #define OP_LDR_FROM_SP_OFFSET(rlo_dest, word_offset) (0x9800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) 293 int word_offset = local_num;
300 int word_offset = local_num;
305 #define OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset) (0xa800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) 309 int word_offset = local_num;
315 #define OP_BW_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff)) 316 #define OP_BW_LO(byte_offset) (0xb800 | (((byte_offset) >> 1) & 0x07ff)) 319 mp_uint_t dest = get_label_dest(as, label);
322 if (dest != (
mp_uint_t)-1 && rel <= -4) {
325 if (SIGNED_FIT12(rel)) {
338 mp_uint_t dest = get_label_dest(as, label);
341 if (dest != (
mp_uint_t)-1 && rel <= -4) {
344 if (SIGNED_FIT9(rel)) {
356 #define OP_BLX(reg) (0x4780 | ((reg) << 3)) 357 #define OP_SVC(arg) (0xdf00 | (arg)) 380 #endif // MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB
void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src)
uint8_t * mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write)
#define ASM_THUMB_FORMAT_9_WORD_TRANSFER
#define ASM_THUMB_FORMAT_9_LDR
void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num)
#define ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset)
#define ASM_THUMB_REG_R15
void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num)
bool asm_thumb_b_n_label(asm_thumb_t *as, uint label)
void asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i32_src)
void mp_asm_base_data(mp_asm_base_t *as, unsigned int bytesize, uintptr_t val)
void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int i32_src)
void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src)
bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool wide)
void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32)
void asm_thumb_exit(asm_thumb_t *as)
void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src)
bool asm_thumb_bl_label(asm_thumb_t *as, uint label)
void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label)
#define ASM_THUMB_OP_MOVW
void asm_thumb_op16(asm_thumb_t *as, uint op)
void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num_dest, uint rlo_src)
void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2)
void asm_thumb_b_label(asm_thumb_t *as, uint label)
void asm_thumb_end_pass(asm_thumb_t *as)
void asm_thumb_entry(asm_thumb_t *as, int num_locals)
void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp)
#define ASM_THUMB_OP_MOVT