py/emitinlinerv32: Add Zba opcodes to the inline assembler.

This commit adds support for Zba opcodes to the RV32 inline assembler.

Three new opcodes were added, SH1ADD, SH2ADD, and SH3ADD, which performs
a scaled addition (by 1, 2, or 3 bits respectively).  At the moment only
qemu's VIRT_RV32 and rp2's RPI_PICO2/RPI_PICO2_W ports support these
opcodes (the latter only when using the RISCV variant).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2025-07-07 22:09:25 +02:00
parent 965c77ade9
commit 40dbf77415
7 changed files with 146 additions and 87 deletions

View File

@@ -0,0 +1,18 @@
@micropython.asm_rv32
def test_sh1add(a0, a1):
sh1add(a0, a0, a1)
@micropython.asm_rv32
def test_sh2add(a0, a1):
sh2add(a0, a0, a1)
@micropython.asm_rv32
def test_sh3add(a0, a1):
sh3add(a0, a0, a1)
print(hex(test_sh1add(10, 20)))
print(hex(test_sh2add(10, 20)))
print(hex(test_sh3add(10, 20)))

View File

@@ -0,0 +1,3 @@
0x28
0x3c
0x64