39 #define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000) 47 "mrc p15, 0, r15, c7, c10, 3\n" 50 "mcr p15, 0, r0, c7, c7, 0\n" 72 return 0x92d0000 | (reglist & 0xFFFF);
77 return 0x8bd0000 | (reglist & 0xFFFF);
82 return 0x1a00000 | (rd << 12) | rn;
87 return 0x3a00000 | (rd << 12) | imm;
92 return 0x3e00000 | (rd << 12) | imm;
97 return 0x2800000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
102 return 0x0800000 | (rn << 16) | (rd << 12) | rm;
107 return 0x2400000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
112 return 0x0400000 | (rn << 16) | (rd << 12) | rm;
118 return 0x0000090 | (rd << 16) | (rs << 8) | rm;
123 return 0x0000000 | (rn << 16) | (rd << 12) | rm;
128 return 0x0200000 | (rn << 16) | (rd << 12) | rm;
133 return 0x1800000 | (rn << 16) | (rd << 12) | rm;
138 emit_al(as, 0x1200070);
154 if (num_locals < 0) {
169 if (num_locals > 3) {
172 if (num_locals & 1) {
192 emit_al(as, asm_arm_op_push(reglist));
196 emit_al(as, asm_arm_op_pop(reglist));
200 emit_al(as, asm_arm_op_mov_reg(reg_dest, reg_src));
205 if ((imm & 0xFF) == imm) {
206 emit_al(as, asm_arm_op_mov_imm(rd, imm));
207 }
else if (imm < 0 && imm >= -256) {
209 emit_al(as, asm_arm_op_mvn_imm(rd, ~imm));
212 emit_al(as, 0x59f0000 | (rd << 12));
213 emit_al(as, 0xa000000);
220 emit_al(as, 0x58d0000 | (rd << 12) | (local_num << 2));
225 emit_al(as, 0x59d0000 | (rd << 12) | (local_num << 2));
230 emit_al(as, 0x3500000 | (rd << 16) | (imm & 0xFF));
235 emit_al(as, 0x1500000 | (rd << 16) | rn);
239 emit(as, asm_arm_op_mov_imm(rd, 1) | cond);
240 emit(as, asm_arm_op_mov_imm(rd, 0) | (cond ^ (1 << 28)));
245 emit_al(as, asm_arm_op_add_reg(rd, rn, rm));
250 emit_al(as, asm_arm_op_sub_reg(rd, rn, rm));
256 emit_al(as, asm_arm_op_mul_reg(rd, rm, rs));
261 emit_al(as, asm_arm_op_and_reg(rd, rn, rm));
266 emit_al(as, asm_arm_op_eor_reg(rd, rn, rm));
271 emit_al(as, asm_arm_op_orr_reg(rd, rn, rm));
276 emit_al(as, asm_arm_op_add_imm(rd,
ASM_ARM_REG_SP, local_num << 2));
281 emit_al(as, 0x1a00010 | (rd << 12) | (rs << 8) | rd);
286 emit_al(as, 0x1a00050 | (rd << 12) | (rs << 8) | rd);
291 emit_al(as, 0x5900000 | (rn << 16) | (rd << 12) | byte_offset);
296 emit_al(as, 0x1d000b0 | (rn << 16) | (rd << 12));
301 emit_al(as, 0x5d00000 | (rn << 16) | (rd << 12));
306 emit_al(as, 0x5800000 | (rm << 16) | (rd << 12) | byte_offset);
311 emit_al(as, 0x1c000b0 | (rm << 16) | (rd << 12));
316 emit_al(as, 0x5c00000 | (rm << 16) | (rd << 12));
321 emit_al(as, 0x7800100 | (rm << 16) | (rd << 12) | rn);
327 emit_al(as, 0x18000b0 | (rm << 16) | (rd << 12) |
ASM_ARM_REG_R8);
332 emit_al(as, 0x7c00000 | (rm << 16) | (rd << 12) | rn);
336 assert(label < as->base.max_num_labels);
342 if (SIGNED_FIT24(rel)) {
343 emit(as, cond | 0xa000000 | (rel & 0xffffff));
345 printf(
"asm_arm_bcc: branch does not fit in 24 bits\n");
355 if (fun_id < (0x1000 / 4)) {
357 emit_al(as, 0x597f000 | (fun_id << 2));
361 emit_al(as, 0x59f0004 | (reg_temp << 12));
365 emit(as, (
uint) fun_ptr);
368 #endif // MICROPY_EMIT_ARM void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn)
uint8_t * mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write)
void asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm)
void asm_arm_mov_reg_reg(asm_arm_t *as, uint reg_dest, uint reg_src)
void asm_arm_end_pass(asm_arm_t *as)
void asm_arm_strb_reg_reg(asm_arm_t *as, uint rd, uint rm)
void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm)
void asm_arm_entry(asm_arm_t *as, int num_locals)
void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm)
void asm_arm_lsl_reg_reg(asm_arm_t *as, uint rd, uint rs)
void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm)
void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond)
void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm)
void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label)
void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn)
void asm_arm_bkpt(asm_arm_t *as)
void asm_arm_ldr_reg_reg(asm_arm_t *as, uint rd, uint rn, uint byte_offset)
void asm_arm_b_label(asm_arm_t *as, uint label)
void asm_arm_str_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn)
void asm_arm_exit(asm_arm_t *as)
void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn)
void asm_arm_mov_reg_local(asm_arm_t *as, uint rd, int local_num)
void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm)
void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp)
void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num)
void asm_arm_asr_reg_reg(asm_arm_t *as, uint rd, uint rs)
void asm_arm_strb_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn)
void asm_arm_str_reg_reg(asm_arm_t *as, uint rd, uint rm, uint byte_offset)
void asm_arm_push(asm_arm_t *as, uint reglist)
void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm)
void asm_arm_pop(asm_arm_t *as, uint reglist)
void asm_arm_strh_reg_reg(asm_arm_t *as, uint rd, uint rm)
void asm_arm_mov_local_reg(asm_arm_t *as, int local_num, uint rd)
void asm_arm_strh_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn)
void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm)