Kullanıcıdan "*" karakterini girene kadar kullanıcıdan alınan toplam COPS toplamını tamsayı kodunu yazmayı deniyorum. Kullanıcının girdiği zamanBir Karakter ile Integers Loop Ekleme Çıkış
bu kod ve sonlandırma döngü durumu yazdığı "-1" yerine "*" bir:
Çıkış "8 1 ila 4 3 * Toplam" gibi olacaktır. -1 yerine '*' sözdizimi yazmayı denedim ama toplamı vermedi. Kullanıcı "*" karakterini girdiğinde döngüden nasıl çıkabilirim? Bu benim ilk sorum oldu ve işte "-1" için çalışma kodum.
# $s0=Sum, $s1=Checkvalue
.data # Data memory area
prompt: .asciiz "Total: "
.text # Code area
main:
move $s0, $zero # Sum is made "0"
li $s1, -1 # Checkvalue is made "-1"
loop: bne $s0, $s0, exit # Infinite loop is described
li $v0, 5 # Read integer into $v0
syscall # Make the syscall read_int
move $t0, $v0 # Move the integer read into $t0
beq $t0, $s1, exit # If the read value is equal "-1", exit
add $s0, $t0, $s0 # Add the read integer to sum
j loop # Return loop
exit:
li $v0, 4 # Syscall to print string
la $a0, prompt
syscall
move $a0, $s0 # Syscall to print string
li $v0, 1
syscall
li $v0, 10 # Syscall to exit
syscall
# Reference: www.es.ele.tue.nl/~heco/courses/ProcDesign/SPIM.ppt
İkinci sorum benim kullanım stdin ve stdout, sistem fonksiyonları için uygundur, "syscall" kullanılan bu?
Çok teşekkür ederim.
Teşekkür ederiz. Bununla ilgili yeni bir soru yayınladım [here] (http://stackoverflow.com/questions/36296223/comparing-two-strings-in-mips) – bieaisar