瀏覽代碼

Replace mul instruction with a loop for rv32i

Vadim Kaushan 5 年之前
父節點
當前提交
579f68ddf7
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      riscv-rt/asm.S

+ 11 - 0
riscv-rt/asm.S

@@ -84,7 +84,18 @@ _abs_start:
     la sp, _stack_start
     lui t0, %hi(_hart_stack_size)
     add t0, t0, %lo(_hart_stack_size)
+#ifdef __riscv_mul
     mul t0, a2, t0
+#else
+    beqz a2, 2f  // Jump if single-hart
+    mv t1, a2
+    mv t2, t0
+1:
+    add t0, t0, t2
+    addi t1, t1, -1
+    bnez t1, 1b
+2:
+#endif
     sub sp, sp, t0
 
     // Set frame pointer