簡體   English   中英

如何在RISC-V Assembly中打印正數和負數的總和

[英]How to print the total of positive and negative numbers in RISC-V Assembly

該程序存儲一個包含 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) 指令?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM