【问题标题】:Why is this prompting not working? MIPS为什么这个提示不起作用? MIPS
【发布时间】:2013-07-25 09:13:54
【问题描述】:
# PART 1 

    .data   # Data declaration section
sourceprompt:   .ascii  "Enter a source string: "

queryprompt:    .ascii  "Enter a query string: "

replaceprompt:  .ascii  "Enter a replace string: "

nomatch:    .ascii  "Nothing to replace "

source:         .space  256 

query:          .space  256

replace:        .space  256

    .text

main:                       # Start of code section

    li $v0, 4               # Load system call for printing into $v0
    la $a0, sourceprompt            # Load address of string into $a0
    syscall                 # call operating system to perform operation

    li $v0, 8               # Load system call for reading string into $v0
    la $a0, source              # Load byte space into source so string has a place to go
    li $a1  256             # Set the byte space for the string
    syscall

    move $t1, $a0               #move source out of a0 so it doesn't get replaced  

    li $v0, 4               # Load system call for printing into $v0
    la $a0, queryprompt         # Load address of string into $a0
    syscall                 # call operating system to perform operation

    li $v0, 8               # Load system call for reading string into $v0
    la $a0, query               # Load byte space into buffer so string has a place to go
    li $a1  256                 # Set the byte space for the string
    syscall                 # call operating system to perform operation

    move $t2, $a0               #move query into t2


    li $v0, 4               # Load system call for printing into $v0
    la $a0, replaceprompt           # Load address of string into $a0
    syscall                 # call operating system to perform operation

    li $v0, 8               # Load system call for reading string into $v0
    la $a0, replace             # Load byte space into buffer so string has a place to go
    li $a1  256                 # Set the byte space for the string
    syscall                 # call operating system to perform operation

    move $t3, $a0               #move replace into t3

打印

输入源字符串:输入查询字符串:输入替换字符串: 没有什么可以替代的

我不想这样!我要它一一提示!为什么它在做htat?!

【问题讨论】:

    标签: assembly mips


    【解决方案1】:

    这些字符串不是以 null 结尾的。请改用 .asciiz。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-31
      • 2011-04-10
      • 1970-01-01
      • 2018-06-12
      • 2014-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多