. . . . .
# pop chars from stack back into the buffer
stend: li $t1,0 # index of first byte of str buffer
popl:
lw $t0,($sp) # pop a char off the stack
addu $sp,$sp,4
beqz $t0,done # null means empty stack
sb $t0,str($t1) # store at string[$t1]
addu $t1,1 # inc the index
j popl # loop
# print the reversed string
done: li $v0,4 # service code
la $a1,str # address of string
syscall
li $v0,10 # exit
syscall
.data
str: .space 128 # character buffer
Quest 15: Apakah akan lebih mudah jika program ini menggunakan array?
Jawab: Yes
Jawaban yang benar: Mungkin tidak
Tidak ada komentar:
Posting Komentar