
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
another trying of previous file
Typology: Quizzes
1 / 1
This page cannot be seen from the preview
Don't miss anything!
No1.asm - 1 - December 17, 2024 8:00 PM 1: .data 2: sum: .word 0 # Variabel sum diinisialisasi dengan 0 3: i: .word 0 # Variabel i diinisialisasi dengan 0 4: 5: .text 6: .globl main 7: main: 8: # Load variabel sum dan i ke register 9: la $t0, sum # Load alamat sum ke $t 10: lw $t1, 0($t0) # Load nilai sum ke $t1 (sum = 0) 11: la $t2, i # Load alamat i ke $t 12: lw $t3, 0($t2) # Load nilai i ke $t3 (i = 0) 13: 14: while_loop: 15: beq $t3, 10, end_loop # Branch keluar dari loop jika i == 10 16: nop # Delay (setelah branching) 17: 18: # sum = sum + 1 19: addi $t1, $t1, 1 # Tambahkan 1 ke register $t1 (sum = sum + 1) 20: 21: # i = i + 1 22: addi $t3, $t3, 1 # Tambahkan 1 ke register $t3 (i = i + 1) 23: 24: j while_loop # Lompat kembali ke awal while_loop 25: nop # Delay (setelah branching) 26: 27: end_loop: 28: # Simpan nilai akhir dari sum dan i kembali ke memori 29: sw $t1, 0($t0) # Simpan sum kembali ke alamat memori 30: sw $t3, 0($t2) # Simpan i kembali ke alamat memori 31: 32: # Akhiri program 33: li $v0, 10 # Syscall untuk keluar dari program 34: syscall