Assembly - Tinh tong tu 1 den n

.data noti: .asciiz "Nhap n : " res: .asciiz "Ket qua : " .text main: la $a0, noti addi $v0, $0, 4 syscall # nhap n addi $v0, $0, 5 syscall addi $s0, $v0, 0 # n luu trong s0 addi $s1, $0, 0 # khoi tao s1 = 0 -> tong addi $t1, $0, 1 # khoi tao t1 = 1 -> bien dem lap: # quy trinh tinh tong add $s1, $s1, $t1 # s1 = s1 + t1 addi $t1, $t1, 1 # t1++ ble $t1, $s0 lap # while (t1 <= n) # in thong bao ket qua la $a0, res addi $v0, $0, 4 syscall #in ket qua addi $a0, $s1, 0 addi $v0, $0, 1 syscall

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.