如何在分配的空间中存储以ASCII转换的计数器寄存器中包含的值

时间:2019-05-03 08:03:30

标签: assembly mips qtspim

我有一个from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC 循环,以这种方式检查字符串中是否存在Char,并将其索引存储在另一个索引中:

伪代码:

for

这是我在MIPS中尝试过的

MIPS:

for (x = 0; x < string.len(); x++) {
    if (string[x] == "A") {
        new_string.append(x)
    }
}

在这种模式下,我将用 add $t0, $zero, $zero # $t0 is the counter loop: blt $s2, $t0, Exit # $s2 have the string.len() add $s0, $s1, $t0 # point to the X char # ($s1 is the string address) lb $t1, 0($s0) bne $t1, 0x41, endLoop # if $t1 != "A" continue sb $t0, 0($s4) # store in newstring the X value addi $s4, $s4, 1 # point to the next space of newstring endLoop: addi $t0, $t0, 1 # increment X j loop Exit: 将数字存储在缓冲区中。我需要以ASCII表示形式转换该值。

输入字符串的最大长度可以为256。因此,我需要考虑该限制的表示形式。

我需要ASCII表示,因为输出字符串将由其他函数处理,该函数使用ASCII属性对输入字符串进行加密。

1 个答案:

答案 0 :(得分:0)

在增加目标地址时,您错误地使用了$s3。应该是addi $s4, $s4, 1

此外,x <= string.len()是错误的结束条件。从0开始,它应该是x < string.len()

相关问题