简体   繁体   English

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

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

The program stores an array of 25 integers (words).该程序存储一个包含 25 个整数(字)的数组。 Then calculate the sum of the positive numbers and the sum of the negative numbers, then print the total of both positive and negative numbers.然后计算正数之和和负数之和,然后打印正数和负数的总和。

Error Messages:错误信息:

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

Print and Exit Code:打印和退出代码:

    #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    

You are using v0 registers which are only available with vector extension.您正在使用仅适用于向量扩展的 v0 寄存器。 If you toolchain.如果你的工具链。

The compiler and the "standard" binutils of the gnu toolchain don't seem supporting it yet. gnu 工具链的编译器和“标准”binutils 似乎还不支持它。 There is a dedicated binutils branch https://github.com/riscv/riscv-binutils-gdb/tree/rvv-1.0.x .有一个专用的 binutils 分支https://github.com/riscv/riscv-binutils-gdb/tree/rvv-1.0.x

LLVM also is not supporting it also. LLVM 也不支持它。 How do I use the RISC-V Vector (RVV) instructions in LLVM IR? 如何在 LLVM IR 中使用 RISC-V 向量 (RVV) 指令?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM