如何在RISC-V汇编中打印正数和负数的总数

  • 本文关键字:打印 RISC-V 汇编 assembly riscv
  • 更新时间 :
  • 英文 :


程序存储一个由25个整数(单词(组成的数组。然后计算正数的和和和负数的和,然后打印正数和负数的总和。

错误消息:

Error in /Users/COD/subtractandadd.asm line 76 column 15: "v0": operand is of incorrect type
Error in /Users/COD/subtractandadd.asm line 80 column 15: "v0": operand is of incorrect type
Error in /Users/COD/subtractandadd.asm line 81 column 12: "la": Too many or incorrectly formatted operands. Expected: la t1,label  
Error in /Users/COD/subtractandadd.asm line 85 column 15: "v0": operand is of incorrect type
Error in /Users/COD/subtractandadd.asm line 89 column 15: "v0": operand is of incorrect type
Error in /Users/COD/subtractandadd.asm line 90 column 12: "la": Too many or incorrectly formatted operands. Expected: la t1,label  
Error in /Users/COD/subtractandadd.asm line 92 column 11: "v0": operand is of incorrect type

打印和退出代码:

#exit and print     
exit:

#print the positive numbers total
li v0,4
la a0,totalPositive
ecall
#print the +ve sum
li v0,1
la a0,($s1)
ecall 

#print the negative total
li v0,4
la a0,totalNegative
ecall
#print the -ve sum
li v0,1
la a0,($s2)
ecall
li v0,10 #end of program exit
ecall    

您使用的是v0寄存器,只有矢量扩展才可用。如果你使用工具链。

编译器和";标准";gnu工具链的binutils似乎还不支持它。有一个专用的binutils分支https://github.com/riscv/riscv-binutils-gdb/tree/rvv-1.0.x.

LLVM也不支持它。如何在LLVM IR中使用RISC-V矢量(RVV(指令?

最新更新