[英]String input in mips is not read as the way I read it when I set its value in data segment
[英]How do I input a string into the text segment instead of the data segment in assembly (MIPS)
我有一項作業,要求我將給定字符串的每個小寫字母更改為大寫字母。
我的問題是教授要求我們將字符串輸入文本段而不是數據段。
我試過使用lw
和sw
但它不起作用。 有沒有其他辦法? (當字符串在數據段中時,我的程序工作)
這是我到目前為止:
.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
使用 smc 選項。
https://courses.missouristate.edu/KenVollmar/MARS/Help/MarsHelpCommand.html
例子:
java Mars4_5.jar smc mips1.asm
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.