Files
micropython/ports/qemu/test-frzmpy/frozen_asm_rv32.py
Alessandro Gatti 268acb714d py/emitinlinerv32: Add inline assembler support for RV32.
This commit adds support for writing inline assembler functions when
targeting a RV32IMC processor.

Given that this takes up a bit of rodata space due to its large
instruction decoding table and its extensive error messages, it is
enabled by default only on offline targets such as mpy-cross and the
qemu port.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-01-02 11:49:10 +11:00

32 lines
497 B
Python

# Test freezing inline-asm code.
# ruff: noqa: F821 - @asm_rv32 decorator adds names to function scope
import micropython
@micropython.asm_rv32
def asm_add(a0, a1):
add(a0, a0, a1)
@micropython.asm_rv32
def asm_add1(a0) -> object:
slli(a0, a0, 1)
addi(a0, a0, 3)
@micropython.asm_rv32
def asm_cast_bool(a0) -> bool:
pass
@micropython.asm_rv32
def asm_shift_int(a0) -> int:
slli(a0, a0, 29)
@micropython.asm_rv32
def asm_shift_uint(a0) -> uint:
slli(a0, a0, 29)