summaryrefslogtreecommitdiff
path: root/py/asmarm.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-03-18 12:29:11 +1100
committerDamien George <damien@micropython.org>2024-03-19 10:31:36 +1100
commitf52b0d0ff1788225fd61a748e0786aa90e953481 (patch)
tree61f99662e12760408831b85444477fe46212bbb9 /py/asmarm.h
parentd92dff881ca99281893b1d77eee4bf2eca25d0c8 (diff)
py/asm: Add ASM_NOT_REG and ASM_NEG_REG macros for unary ops.
ASM_NOT_REG is optional, it can be synthesised by xor(reg, -1). ASM_NEG_REG can also be synthesised with a subtraction, but most architectures have a dedicated instruction for it. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/asmarm.h')
-rw-r--r--py/asmarm.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/asmarm.h b/py/asmarm.h
index 81c3f7b1c..4a4253aef 100644
--- a/py/asmarm.h
+++ b/py/asmarm.h
@@ -94,8 +94,10 @@ void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm);
void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn);
// arithmetic
+void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm);
void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
+void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm);
void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
@@ -188,6 +190,8 @@ void asm_arm_bx_reg(asm_arm_t *as, uint reg_src);
#define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_arm_mov_reg_local_addr((as), (reg_dest), (local_num))
#define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_arm_mov_reg_pcrel((as), (reg_dest), (label))
+#define ASM_NOT_REG(as, reg_dest) asm_arm_mvn_reg_reg((as), (reg_dest), (reg_dest))
+#define ASM_NEG_REG(as, reg_dest) asm_arm_rsb_reg_reg_imm((as), (reg_dest), (reg_dest), 0)
#define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_arm_lsl_reg_reg((as), (reg_dest), (reg_shift))
#define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_arm_lsr_reg_reg((as), (reg_dest), (reg_shift))
#define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_arm_asr_reg_reg((as), (reg_dest), (reg_shift))