[英]How do I input a string into the text segment instead of the data segment in assembly (MIPS)
I have an assignment in which I am asked to change each lowercase letter of a given string to an uppercase letter.我有一项作业,要求我将给定字符串的每个小写字母更改为大写字母。
My problem is that the professor has asked us to input the string into the text segment and not the data segment.我的问题是教授要求我们将字符串输入文本段而不是数据段。
I have tried using lw
and sw
but it doesn't work.我试过使用lw
和sw
但它不起作用。 Is there any other way?有没有其他办法? (My program works when the string is in the data segment) (当字符串在数据段中时,我的程序工作)
This is what I have so far:这是我到目前为止:
.data
str: .space 100
textlow: .asciiz "This is a sample text!"
.text
main:
li $t0, 0
loop:
lb $t1, textlow($t0)
beq $t1, 0, exit
blt $t1, 'a', diff
bgt $t1, 'z', diff
sub $t1, $t1, 32
sb $t1, textlow($t0)
diff:
addi $t0, $t0, 1
j loop
exit:
li $v0, 10
syscall
use smc option.使用 smc 选项。
https://courses.missouristate.edu/KenVollmar/MARS/Help/MarsHelpCommand.html https://courses.missouristate.edu/KenVollmar/MARS/Help/MarsHelpCommand.html
example:例子:
java Mars4_5.jar smc mips1.asm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.