.data
m_success:.asciiz
"\r\nSuccess!Location:"
m_fail: .asciiz
"\r\nFail!\r\n"
print_line:.asciiz
"\r\n"
buffer: .space 100
.text
.globl main
main: la $a0,buffer
la $a1,100
li $v0,8 #read string
syscall
cin: li $v0, 12 #read character
syscall
li $t0,63 #'?'
sub $t1, $t0, $v0
beqz $t1,exit
la $s1, buffer
li $t0,0
loop: lb $s0,($s1)
sub $t1,$v0,$s0
beqz $t1,success
addi $t0,$t0,1
beq $t0,$a1,fail
addi $s1,$s1,1
j loop
success:la $a0, m_success
li $v0, 4 # print string
syscall
addi $a0, $t0, 1
li $v0, 1 # print integer
syscall
la $a0, print_line
li $v0, 4
syscall
j cin
fail: la $a0, m_fail
li $v0, 4
syscall
j cin
exit: li $v0, 10
syscall
计组第3周互评作业2
最新推荐文章于 2023-01-25 23:33:53 发布