Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用缓冲区和内存分配来确定输入字符串的长度。因此,假设我分配了一些内存并读取了一个字符串并将其存储到缓冲区中。那我怎么知道字符串有多长呢?
从头开始计数,直到找到空字符 (0)。
就像是:
la $t0 string loop: lb $t1 0($t0) beq $t1 $zero end addi $t0 $t0 1 j loop end: la $t1 string sub $t3 $t0 $t1 #$t3 now contains the length of the string