26 #ifndef MICROPY_INCLUDED_PY_ASMX86_H 27 #define MICROPY_INCLUDED_PY_ASMX86_H 46 #define ASM_X86_REG_EAX (0) 47 #define ASM_X86_REG_ECX (1) 48 #define ASM_X86_REG_EDX (2) 49 #define ASM_X86_REG_EBX (3) 50 #define ASM_X86_REG_ESP (4) 51 #define ASM_X86_REG_EBP (5) 52 #define ASM_X86_REG_ESI (6) 53 #define ASM_X86_REG_EDI (7) 59 #define ASM_X86_REG_ARG_1 ASM_X86_REG_EAX 60 #define ASM_X86_REG_ARG_2 ASM_X86_REG_ECX 61 #define ASM_X86_REG_ARG_3 ASM_X86_REG_EDX 62 #define ASM_X86_REG_ARG_4 ASM_X86_REG_EBX 63 #define ASM_X86_REG_ARG_5 ASM_X86_REG_ESI 66 #define ASM_X86_CC_JB (0x2) // below, unsigned 67 #define ASM_X86_CC_JZ (0x4) 68 #define ASM_X86_CC_JE (0x4) 69 #define ASM_X86_CC_JNZ (0x5) 70 #define ASM_X86_CC_JNE (0x5) 71 #define ASM_X86_CC_JL (0xc) // less, signed 72 #define ASM_X86_CC_JGE (0xd) // greater or equal, signed 73 #define ASM_X86_CC_JLE (0xe) // less or equal, signed 74 #define ASM_X86_CC_JG (0xf) // greater, signed 81 static inline void asm_x86_end_pass(
asm_x86_t *as) {
120 #define ASM_WORD_SIZE (4) 122 #define REG_RET ASM_X86_REG_EAX 123 #define REG_ARG_1 ASM_X86_REG_ARG_1 124 #define REG_ARG_2 ASM_X86_REG_ARG_2 125 #define REG_ARG_3 ASM_X86_REG_ARG_3 126 #define REG_ARG_4 ASM_X86_REG_ARG_4 127 #define REG_ARG_5 ASM_X86_REG_ARG_5 130 #define REG_TEMP0 ASM_X86_REG_EAX 131 #define REG_TEMP1 ASM_X86_REG_ECX 132 #define REG_TEMP2 ASM_X86_REG_EDX 135 #define REG_LOCAL_1 ASM_X86_REG_EBX 136 #define REG_LOCAL_2 ASM_X86_REG_ESI 137 #define REG_LOCAL_3 ASM_X86_REG_EDI 138 #define REG_LOCAL_NUM (3) 140 #define ASM_T asm_x86_t 141 #define ASM_END_PASS asm_x86_end_pass 142 #define ASM_ENTRY asm_x86_entry 143 #define ASM_EXIT asm_x86_exit 145 #define ASM_JUMP asm_x86_jmp_label 146 #define ASM_JUMP_IF_REG_ZERO(as, reg, label) \ 148 asm_x86_test_r8_with_r8(as, reg, reg); \ 149 asm_x86_jcc_label(as, ASM_X86_CC_JZ, label); \ 151 #define ASM_JUMP_IF_REG_NONZERO(as, reg, label) \ 153 asm_x86_test_r8_with_r8(as, reg, reg); \ 154 asm_x86_jcc_label(as, ASM_X86_CC_JNZ, label); \ 156 #define ASM_JUMP_IF_REG_EQ(as, reg1, reg2, label) \ 158 asm_x86_cmp_r32_with_r32(as, reg1, reg2); \ 159 asm_x86_jcc_label(as, ASM_X86_CC_JE, label); \ 161 #define ASM_CALL_IND(as, ptr, idx) asm_x86_call_ind(as, ptr, mp_f_n_args[idx], ASM_X86_REG_EAX) 163 #define ASM_MOV_REG_TO_LOCAL asm_x86_mov_r32_to_local 164 #define ASM_MOV_IMM_TO_REG asm_x86_mov_i32_to_r32 165 #define ASM_MOV_ALIGNED_IMM_TO_REG asm_x86_mov_i32_to_r32_aligned 166 #define ASM_MOV_IMM_TO_LOCAL_USING(as, imm, local_num, reg_temp) \ 168 asm_x86_mov_i32_to_r32(as, (imm), (reg_temp)); \ 169 asm_x86_mov_r32_to_local(as, (reg_temp), (local_num)); \ 171 #define ASM_MOV_LOCAL_TO_REG asm_x86_mov_local_to_r32 172 #define ASM_MOV_REG_REG(as, reg_dest, reg_src) asm_x86_mov_r32_r32((as), (reg_dest), (reg_src)) 173 #define ASM_MOV_LOCAL_ADDR_TO_REG asm_x86_mov_local_addr_to_r32 175 #define ASM_LSL_REG(as, reg) asm_x86_shl_r32_cl((as), (reg)) 176 #define ASM_ASR_REG(as, reg) asm_x86_sar_r32_cl((as), (reg)) 177 #define ASM_OR_REG_REG(as, reg_dest, reg_src) asm_x86_or_r32_r32((as), (reg_dest), (reg_src)) 178 #define ASM_XOR_REG_REG(as, reg_dest, reg_src) asm_x86_xor_r32_r32((as), (reg_dest), (reg_src)) 179 #define ASM_AND_REG_REG(as, reg_dest, reg_src) asm_x86_and_r32_r32((as), (reg_dest), (reg_src)) 180 #define ASM_ADD_REG_REG(as, reg_dest, reg_src) asm_x86_add_r32_r32((as), (reg_dest), (reg_src)) 181 #define ASM_SUB_REG_REG(as, reg_dest, reg_src) asm_x86_sub_r32_r32((as), (reg_dest), (reg_src)) 182 #define ASM_MUL_REG_REG(as, reg_dest, reg_src) asm_x86_mul_r32_r32((as), (reg_dest), (reg_src)) 184 #define ASM_LOAD_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem32_to_r32((as), (reg_base), 0, (reg_dest)) 185 #define ASM_LOAD_REG_REG_OFFSET(as, reg_dest, reg_base, word_offset) asm_x86_mov_mem32_to_r32((as), (reg_base), 4 * (word_offset), (reg_dest)) 186 #define ASM_LOAD8_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem8_to_r32zx((as), (reg_base), 0, (reg_dest)) 187 #define ASM_LOAD16_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem16_to_r32zx((as), (reg_base), 0, (reg_dest)) 188 #define ASM_LOAD32_REG_REG(as, reg_dest, reg_base) asm_x86_mov_mem32_to_r32((as), (reg_base), 0, (reg_dest)) 190 #define ASM_STORE_REG_REG(as, reg_src, reg_base) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) 191 #define ASM_STORE_REG_REG_OFFSET(as, reg_src, reg_base, word_offset) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 4 * (word_offset)) 192 #define ASM_STORE8_REG_REG(as, reg_src, reg_base) asm_x86_mov_r8_to_mem8((as), (reg_src), (reg_base), 0) 193 #define ASM_STORE16_REG_REG(as, reg_src, reg_base) asm_x86_mov_r16_to_mem16((as), (reg_src), (reg_base), 0) 194 #define ASM_STORE32_REG_REG(as, reg_src, reg_base) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 0) 196 #endif // GENERIC_ASM_API 198 #endif // MICROPY_INCLUDED_PY_ASMX86_H
void asm_x86_entry(asm_x86_t *as, mp_uint_t num_locals)
void asm_x86_call_ind(asm_x86_t *as, void *ptr, mp_uint_t n_args, int temp_r32)
void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_setcc_r8(asm_x86_t *as, mp_uint_t jcc_type, int dest_r8)
void asm_x86_mul_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32)
void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp)
void asm_x86_test_r8_with_r8(asm_x86_t *as, int src_r32_a, int src_r32_b)
void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32)
struct _asm_x86_t asm_x86_t
void asm_x86_mov_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_cmp_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32_b)
void asm_x86_shl_r32_cl(asm_x86_t *as, int dest_r32)
void asm_x86_jcc_label(asm_x86_t *as, mp_uint_t jcc_type, mp_uint_t label)
void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32)
void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32)
void asm_x86_exit(asm_x86_t *as)
void asm_x86_mov_local_addr_to_r32(asm_x86_t *as, int local_num, int dest_r32)
void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_jmp_label(asm_x86_t *as, mp_uint_t label)
void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_mov_i32_to_r32_aligned(asm_x86_t *as, int32_t src_i32, int dest_r32)
void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp)
void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp)
void asm_x86_sar_r32_cl(asm_x86_t *as, int dest_r32)
void asm_x86_mov_local_to_r32(asm_x86_t *as, int src_local_num, int dest_r32)
void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32)
void asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32)
void asm_x86_mov_r32_to_local(asm_x86_t *as, int src_r32, int dest_local_num)