简体   繁体   English

RISC-V 循环遍历单词数组

[英]RISC-V Looping Through Array of Words

In my assignment for class the professor asked us to loop through an given array of 10 numbers and print them, and the following was provided as skeleton code:在我的课堂作业中,教授要求我们循环遍历给定的 10 个数字数组并打印它们,以下是作为骨架代码提供的:

.data
arrayOfNums:
.word 0
.word 1
.word 255
.word 65536
.word 4294967295
.word 22
.word 314159
.word 161803
.word 42
.word 131929

K: .word 1337

.text
.globl main

main:
*Code goes here*

I don't understand how to go down the list of words from arrayOfNums.我不明白如何从 arrayOfNums 中查找单词列表。 This is my first time coming into contact with any sort of assembly language so a detailed explanation would be extremely helpful, thanks guys这是我第一次接触任何类型的汇编语言,所以详细的解释会非常有帮助,谢谢大家

In your code you have to solve the following tasks:在您的代码中,您必须解决以下任务:

  • load the start address of your array into a register将数组的起始地址加载到寄存器中
  • loop over the array, ieload each element from the current address,循环遍历数组,即从当前地址加载每个元素,
  • print the loaded value with the right ecall使用正确的ecall打印加载的值
  • increment the address of the current element by as many bytes as a word occupies,将当前元素的地址增加一个字占用的字节数,
  • conditionally branch to the start of the loop if the address is still part of the array - hint: K symbolizes the address that immediately follows your last array element如果地址仍然是数组的一部分,则有条件地分支到循环的开头 - 提示: K表示紧跟在最后一个数组元素之后的地址
  • call an exit ecall to terminate your program调用退出ecall以终止您的程序

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

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