2013-07-24 1 views
0
# 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 

PRINTS이 프롬프트가 작동하지 않는 이유는 무엇입니까? MIPS

는 소스 문자열을 입력 : 쿼리 문자열을 입력하십시오 대체 문자열을 입력 : 내가 원하지 않는다 아무것도

를 교체하지하기! 나는 그것을 하나씩 묻기를 원한다! 왜 htat하고 있니? !!

답변

2

해당 문자열은 null로 끝나지 않습니다. 대신 .asciiz를 사용하십시오.