SlideShare a Scribd company logo
1 of 8
.data
EnterA : .asciiz "Nhap A "
EnterB : .asciiz "Nhap B "
Menu : .asciiz "----------------------------Menu------------------------nn1. Tong a
va bn2. Hieu a va bn3. Tich a va bn4. Thuong a va bn5. Kiem tra a va b la so
nguyen to ?n6. Kiem tra a va b la so hoan thien ?n7. Kiem tra a va b la so chinh
phuong ?n8. Kiem tra a va b la so doi xung ?n0. Thoatn--------------------------------------------------------------------n"
Chose: .asciiz "Chon "
Tong : .asciiz "Tong : "
Hieu : .asciiz "Hieu : "
Tich : .asciiz "Tich : "
Thuong : .asciiz "Thuong : "
Result : .asciiz "Ket qua: "
True_Nt_A : .asciiz "A la so nguyen to"
False_Nt_A : .asciiz "A khong phai so nguyen to"
True_Nt_B : .asciiz "nB la so nguyen to"
False_Nt_B : .asciiz "nB khong phai so nguyen to"
True_Ht_A:
False_Ht_A
True_Ht_B:
False_Ht_B

.asciiz "A la so hoan thien"
: .asciiz "A khong phai so hoan thien"
.asciiz "nB la so hoan thien"
: .asciiz "nB khong phai so hoan thien"

True_Cp_A:
False_Cp_A
True_Cp_B:
False_Cp_B

.asciiz "A la so chinh phuong"
: .asciiz "A khong phai so chinh phuong"
.asciiz "nB la so chinh phuong"
: .asciiz "nB khong phai so chinh phuong"

True_Dx_A:
False_Dx_A
True_Dx_B:
False_Dx_B

.asciiz "A la so doi xung"
: .asciiz "A khong phai so doi xung"
.asciiz "nB la so doi xung"
: .asciiz "nB khong phai so doi xung"

.text
.globl main
main:

li $v0,4 #print "Nhap a"
la $a0,EnterA
syscall
li $v0,5 #scan a
syscall
move $s0,$v0
li $v0,4 #print "Nhap b"
la $a0,EnterB
syscall
li $v0,5 #scan b
syscall
move $s1,$v0
li $v0,4 #print "Menu"
la $a0,Menu
syscall
li $v0,4 #print "Chon"
la $a0,Chose
syscall
li $v0,5 #scan k
syscall
move $s2,$v0
li $v0,4 #print "Ket qua : "
la $a0,Result
syscall
addi $t0,$s2,-1
bne $t0,$0,Subtraction #k==0 Jump -> Exit
add $s3,$s1,$s0 #S=a+b
li $v0,4 #print "Tong : "
la $a0,Tong
syscall
move $a0,$s3
li $v0,1 #print "Tong"
syscall
j Exit
Subtraction:
addi $t0,$s2,-2
bne $t0,$0,Multiplication
sub $s3,$s0,$s1 #S=a-b
li $v0,4 #print "Hieu : "
la $a0,Hieu
syscall
move $a0,$s3
li $v0,1 #print Hieu
syscall
j Exit
Multiplication:
addi $t0,$s2,-3
bne $t0,$0,Division
mult $s1,$s0 #S=a*b
mflo $s3
li $v0,4 #print "Tich : "
la $a0,Tich
syscall
move $a0,$s3
li $v0,1 #print Tich
syscall
j Exit
Division:
addi $t0,$s2,-4
bne $t0,$0,Prime
div $s0,$s1 #S=a/b
mflo $s3
li $v0,4 #print "Thuong : "
la $a0,Thuong
syscall
move $a0,$s3
li $v0,1 #print Thuong
syscall

Prime:
addi $t0,$s2,-5
bne $t0,$0,CompleteNumber
addi $s4,$0,2 #i=2
addi $s5,$0,1 #check = 1
Nt_A_Loop:
slt $t0,$s4,$s0 #i<a i>=a thi thoat i<a
beq $t0,$0,Nt_A_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat
div $s0,$s4 # a%i
mfhi $s6 #temp = a%i
bne $s6,$0,Nt_A_ExitIf
add $s5,$0,$0
j Nt_A_ExitLoop
Nt_A_ExitIf:
addi $s4,$s4,1
j Nt_A_Loop
Nt_A_ExitLoop:
bne $s5,$0,Nt_A_CheckIf
li $v0,4 #print "A khong la so nguyen to "
la $a0,False_Nt_A
syscall
j Nt_A_CheckElse
Nt_A_CheckIf:
li $v0,4 #print "A la so nguyen to "
la $a0,True_Nt_A
syscall
Nt_A_CheckElse:
addi $s4,$0,2 #i=2
addi $s5,$0,1 #check = 1
Nt_B_Loop:
slt $t0,$s4,$s1 #i<a i>=a thi thoat i<a
beq $t0,$0,Nt_B_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat
div $s1,$s4 # a%i
mfhi $s6 #temp = a%i
bne $s6,$0,Nt_B_ExitIf
add $s5,$0,$0
j Nt_B_ExitLoop
Nt_B_ExitIf:
addi $s4,$s4,1
j Nt_B_Loop
Nt_B_ExitLoop:
bne $s5,$0,Nt_B_CheckIf
li $v0,4 #print "A khong la so nguyen to "
la $a0,False_Nt_B
syscall
j Nt_B_CheckElse
Nt_B_CheckIf:
li $v0,4 #print "A la so nguyen to "
la $a0,True_Nt_B
syscall
Nt_B_CheckElse:
j Exit
CompleteNumber:
addi $t0,$s2,-6
bne $t0,$0,SquareNumber
addi $s3,$0,0 #s=0
addi $s4,$0,1 #i = 1
Ht_A_Loop:
slt $t0,$s4,$s0 #i<a i>=a thi thoat i<a
beq $t0,$0,Ht_A_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat
div $s0,$s4 # a%i
mfhi $s6 #temp = a%i
bne $s6,$0,Ht_A_ExitIf
add $s3,$s3,$s4
Ht_A_ExitIf:
addi $s4,$s4,1
j Ht_A_Loop
Ht_A_ExitLoop:
bne $s3,$s0,Ht_A_CheckIf
li $v0,4 #print "A la so hoan thien"
la $a0,True_Ht_A
syscall
j Ht_A_CheckElse
Ht_A_CheckIf:
li $v0,4 #print "A khong la so hoan thien"
la $a0,False_Ht_A
syscall
Ht_A_CheckElse:
addi $s3,$0,0 #s=0
addi $s4,$0,1 #i = 1
Ht_B_Loop:
slt $t0,$s4,$s1 #i<a i>=a thi thoat i<a
beq $t0,$0,Ht_B_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat
div $s1,$s4 # a%i
mfhi $s6 #temp = a%i
bne $s6,$0,Ht_B_ExitIf
add $s3,$s3,$s4
Ht_B_ExitIf:
addi $s4,$s4,1
j Ht_B_Loop
Ht_B_ExitLoop:
bne $s3,$s1,Ht_B_CheckIf
li $v0,4 #print "A la so hoan thien"
la $a0,True_Ht_B
syscall
j Ht_B_CheckElse
Ht_B_CheckIf:
li $v0,4 #print "A khong la so hoan thien"
la $a0,False_Ht_B
syscall
Ht_B_CheckElse:
j Exit
SquareNumber:
addi $t0,$s2,-7
bne $t0,$0,SymmetryNumber
addi $s5,$0,0 #check=0
addi $s4,$0,1 #i = 1
Cp_A_Loop:
slt $t0,$s4,$s0 #i<a i>=a thi thoat i<a
beq $t0,$0,Cp_A_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat
mult $s4,$s4 # a*a
mflo $s6 #temp = a*a
bne $s6,$s0,Cp_A_ExitIf
addi $s5,$0,1 #check=1
j Cp_A_ExitLoop
Cp_A_ExitIf:
addi $s4,$s4,1
j Cp_A_Loop
Cp_A_ExitLoop:
beq $s5,$0,Cp_A_CheckIf
li $v0,4 #print "A la so hoan thien"
la $a0,True_Cp_A
syscall
j Cp_A_CheckElse
Cp_A_CheckIf:
li $v0,4 #print "A khong la so hoan thien"
la $a0,False_Cp_A
syscall
Cp_A_CheckElse:

addi $s5,$0,0 #check=0
addi $s4,$0,1 #i = 1
Cp_B_Loop:
slt $t0,$s4,$s1 #i<a i>=a thi thoat i<a
beq $t0,$0,Cp_B_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat
mult $s4,$s4 # a*a
mflo $s6 #temp = a*a
bne $s6,$s1,Cp_B_ExitIf
addi $s5,$0,1 #check=1
j Cp_B_ExitLoop
Cp_B_ExitIf:
addi $s4,$s4,1
j Cp_B_Loop
Cp_B_ExitLoop:
beq $s5,$0,Cp_B_CheckIf
li $v0,4 #print "A la so hoan thien"
la $a0,True_Cp_B
syscall
j Cp_B_CheckElse
Cp_B_CheckIf:
li $v0,4 #print "A khong la so hoan thien"
la $a0,False_Cp_B
syscall
Cp_B_CheckElse:

j Exit
SymmetryNumber:
addi $t0,$s2,-8
bne $t0,$0,Exit
addi $s3,$0,0 #dao=0
add $s4,$s0,$0 #m=a
Dx_A_Loop:
slt $t0,$0,$s4 #0>=m thi 0, 0<m thi 1
beq $t0,$0,Dx_A_ExitLoop # 0<=m thi thoat
addi $s7,$0,10 # $s7 = 10
mult $s3,$s7 # dao*10
mflo $s3 # dao=dao*10
div $s4,$s7
mfhi $s6 # temp = m % 10
add $s3,$s3,$s6 # dao = dao + temp
div $s4,$s7
mflo $s4
j Dx_A_Loop
Dx_A_ExitLoop:
bne $s3,$s0,Dx_A_CheckIf
li $v0,4
la $a0,True_Dx_A
syscall
j Dx_A_CheckElse
Dx_A_CheckIf:
li $v0,4
la $a0,False_Dx_A
syscall
Dx_A_CheckElse:

addi $s3,$0,0 #dao=0
add $s4,$s1,$0 #m=a
Dx_B_Loop:
slt $t0,$0,$s4 #0>=m thi 0, 0<m thi 1
beq $t0,$0,Dx_B_ExitLoop # 0<=m thi thoat
addi $s7,$0,10 # $s7 = 10
mult $s3,$s7 # dao*10
mflo $s3 # dao=dao*10
div $s4,$s7
mfhi $s6 # temp = m % 10
add $s3,$s3,$s6 # dao = dao + temp
div $s4,$s7
mflo $s4
j Dx_B_Loop
Dx_B_ExitLoop:
bne $s3,$s1,Dx_B_CheckIf
li $v0,4
la $a0,True_Dx_B
syscall
j Dx_B_CheckElse
Dx_B_CheckIf:
li $v0,4
la $a0,False_Dx_B
syscall
Dx_B_CheckElse:
j Exit
Exit:
li $v0, 10
syscall

More Related Content

What's hot

MATMA - 1.chuong4
MATMA - 1.chuong4MATMA - 1.chuong4
MATMA - 1.chuong4Sai Lemovom
 
Biến ngẫu nhiên liên tục - Xác suất thống kê
Biến ngẫu nhiên liên tục - Xác suất thống kêBiến ngẫu nhiên liên tục - Xác suất thống kê
Biến ngẫu nhiên liên tục - Xác suất thống kêVuKirikou
 
Bai07 bo nho
Bai07   bo nhoBai07   bo nho
Bai07 bo nhoVũ Sang
 
các phân phối xác xuất thường gặp
các phân phối xác xuất thường gặpcác phân phối xác xuất thường gặp
các phân phối xác xuất thường gặpKhoa Nguyễn
 
Kiến trúc máy tính và hợp ngữ bài 02
Kiến trúc máy tính và hợp ngữ bài 02Kiến trúc máy tính và hợp ngữ bài 02
Kiến trúc máy tính và hợp ngữ bài 02Nhóc Nhóc
 
Kiến trúc máy tính và hợp ngữ bài 08
Kiến trúc máy tính và hợp ngữ bài 08Kiến trúc máy tính và hợp ngữ bài 08
Kiến trúc máy tính và hợp ngữ bài 08Nhóc Nhóc
 
[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện
[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện
[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư việnThe Nguyen Manh
 
Bài tập mẫu C và C++ có giải
Bài tập mẫu C và C++ có giảiBài tập mẫu C và C++ có giải
Bài tập mẫu C và C++ có giảiTrung Thanh Nguyen
 
báo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạn
báo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạnbáo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạn
báo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạnnataliej4
 
Trí tuệ nhân tạo "Game cờ Caro"
Trí tuệ nhân tạo "Game cờ Caro"Trí tuệ nhân tạo "Game cờ Caro"
Trí tuệ nhân tạo "Game cờ Caro"Ham Hau
 
BÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG
BÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNGBÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG
BÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNGTrường Phạm
 
Bài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tínhBài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tínhCao Toa
 
Slide đồ án tốt nghiệp
Slide đồ án tốt nghiệpSlide đồ án tốt nghiệp
Slide đồ án tốt nghiệpToan Pham
 
Lập trình c++ có lời giải 2
Lập trình c++ có lời giải 2Lập trình c++ có lời giải 2
Lập trình c++ có lời giải 2Minh Ngoc Tran
 
Hệ điều hành (chương 2)
Hệ điều hành (chương 2)Hệ điều hành (chương 2)
Hệ điều hành (chương 2)realpotter
 
đề thi java ptit
đề thi java ptitđề thi java ptit
đề thi java ptitNguynMinh294
 

What's hot (20)

MATMA - 1.chuong4
MATMA - 1.chuong4MATMA - 1.chuong4
MATMA - 1.chuong4
 
Biến ngẫu nhiên liên tục - Xác suất thống kê
Biến ngẫu nhiên liên tục - Xác suất thống kêBiến ngẫu nhiên liên tục - Xác suất thống kê
Biến ngẫu nhiên liên tục - Xác suất thống kê
 
Bai07 bo nho
Bai07   bo nhoBai07   bo nho
Bai07 bo nho
 
các phân phối xác xuất thường gặp
các phân phối xác xuất thường gặpcác phân phối xác xuất thường gặp
các phân phối xác xuất thường gặp
 
Kiến trúc máy tính và hợp ngữ bài 02
Kiến trúc máy tính và hợp ngữ bài 02Kiến trúc máy tính và hợp ngữ bài 02
Kiến trúc máy tính và hợp ngữ bài 02
 
Kiến trúc máy tính và hợp ngữ bài 08
Kiến trúc máy tính và hợp ngữ bài 08Kiến trúc máy tính và hợp ngữ bài 08
Kiến trúc máy tính và hợp ngữ bài 08
 
[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện
[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện
[Báo cáo] Bài tập lớn Ngôn ngữ lập trình: Quản lý thư viện
 
Bài tập mẫu C và C++ có giải
Bài tập mẫu C và C++ có giảiBài tập mẫu C và C++ có giải
Bài tập mẫu C và C++ có giải
 
báo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạn
báo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạnbáo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạn
báo cáo bài tập lớn phân tích thiết kế hệ thống quản lý khách sạn
 
Chuong04
Chuong04Chuong04
Chuong04
 
Trí tuệ nhân tạo "Game cờ Caro"
Trí tuệ nhân tạo "Game cờ Caro"Trí tuệ nhân tạo "Game cờ Caro"
Trí tuệ nhân tạo "Game cờ Caro"
 
BÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG
BÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNGBÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG
BÀI GIẢNG LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG
 
Bài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tínhBài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tính
 
Slide đồ án tốt nghiệp
Slide đồ án tốt nghiệpSlide đồ án tốt nghiệp
Slide đồ án tốt nghiệp
 
Lập trình c++ có lời giải 2
Lập trình c++ có lời giải 2Lập trình c++ có lời giải 2
Lập trình c++ có lời giải 2
 
Co ban ve_matlab
Co ban ve_matlabCo ban ve_matlab
Co ban ve_matlab
 
Bài giảng Assembly
Bài giảng AssemblyBài giảng Assembly
Bài giảng Assembly
 
Ktmt chuong 3
Ktmt chuong 3Ktmt chuong 3
Ktmt chuong 3
 
Hệ điều hành (chương 2)
Hệ điều hành (chương 2)Hệ điều hành (chương 2)
Hệ điều hành (chương 2)
 
đề thi java ptit
đề thi java ptitđề thi java ptit
đề thi java ptit
 

Viewers also liked

Bai tap mon_lap_trinh_hop_ngu
Bai tap mon_lap_trinh_hop_nguBai tap mon_lap_trinh_hop_ngu
Bai tap mon_lap_trinh_hop_ngulakyos
 
lap trinh assembly cho VXL
lap trinh  assembly cho VXLlap trinh  assembly cho VXL
lap trinh assembly cho VXLThân Khương
 
03 lap trinh hop ngu voi 8086
03 lap trinh hop ngu voi 808603 lap trinh hop ngu voi 8086
03 lap trinh hop ngu voi 8086onlylove511
 
7 can ban assembly
7 can ban assembly7 can ban assembly
7 can ban assemblyLy hai
 
Kiến trúc máy tính và hợp ngữ bài 01
Kiến trúc máy tính và hợp ngữ bài 01Kiến trúc máy tính và hợp ngữ bài 01
Kiến trúc máy tính và hợp ngữ bài 01Nhóc Nhóc
 
Exercicios lista05 hiperestaticas
Exercicios lista05 hiperestaticasExercicios lista05 hiperestaticas
Exercicios lista05 hiperestaticasDouglas Roberto
 
Silladeruedas
SilladeruedasSilladeruedas
Silladeruedassilva9703
 
Perubahan dan pengembangan organisasi
Perubahan dan pengembangan organisasiPerubahan dan pengembangan organisasi
Perubahan dan pengembangan organisasiCendekiawan16
 
40 minutos de la vida de Daniel Chacón y sus amigos
40 minutos de la vida de Daniel Chacón y sus amigos40 minutos de la vida de Daniel Chacón y sus amigos
40 minutos de la vida de Daniel Chacón y sus amigosDaniChacon98
 
«Социология мировых цивилизаций»
«Социология мировых цивилизаций»«Социология мировых цивилизаций»
«Социология мировых цивилизаций»денис климов
 
Cyanobacteria 110107033006-phpapp01
Cyanobacteria 110107033006-phpapp01Cyanobacteria 110107033006-phpapp01
Cyanobacteria 110107033006-phpapp01shamsudin DrGez
 
Othering theory presentation
Othering theory presentationOthering theory presentation
Othering theory presentationSal9594
 
More than a bandage for johnson & johnson's hcm
More than a bandage for johnson & johnson's hcmMore than a bandage for johnson & johnson's hcm
More than a bandage for johnson & johnson's hcmHuman Capital Media
 
Seminar on olap online analytical
Seminar on olap  online analyticalSeminar on olap  online analytical
Seminar on olap online analyticalcyber_fox
 

Viewers also liked (20)

Bai tap mon_lap_trinh_hop_ngu
Bai tap mon_lap_trinh_hop_nguBai tap mon_lap_trinh_hop_ngu
Bai tap mon_lap_trinh_hop_ngu
 
lap trinh assembly cho VXL
lap trinh  assembly cho VXLlap trinh  assembly cho VXL
lap trinh assembly cho VXL
 
Assembly
AssemblyAssembly
Assembly
 
03 lap trinh hop ngu voi 8086
03 lap trinh hop ngu voi 808603 lap trinh hop ngu voi 8086
03 lap trinh hop ngu voi 8086
 
7 can ban assembly
7 can ban assembly7 can ban assembly
7 can ban assembly
 
Kiến trúc máy tính và hợp ngữ bài 01
Kiến trúc máy tính và hợp ngữ bài 01Kiến trúc máy tính và hợp ngữ bài 01
Kiến trúc máy tính và hợp ngữ bài 01
 
baloncesto
baloncestobaloncesto
baloncesto
 
Exercicios lista05 hiperestaticas
Exercicios lista05 hiperestaticasExercicios lista05 hiperestaticas
Exercicios lista05 hiperestaticas
 
Tutorial
TutorialTutorial
Tutorial
 
Saad ca paru
Saad ca paruSaad ca paru
Saad ca paru
 
Anthonys work pp
Anthonys work ppAnthonys work pp
Anthonys work pp
 
Silladeruedas
SilladeruedasSilladeruedas
Silladeruedas
 
Perubahan dan pengembangan organisasi
Perubahan dan pengembangan organisasiPerubahan dan pengembangan organisasi
Perubahan dan pengembangan organisasi
 
40 minutos de la vida de Daniel Chacón y sus amigos
40 minutos de la vida de Daniel Chacón y sus amigos40 minutos de la vida de Daniel Chacón y sus amigos
40 minutos de la vida de Daniel Chacón y sus amigos
 
«Социология мировых цивилизаций»
«Социология мировых цивилизаций»«Социология мировых цивилизаций»
«Социология мировых цивилизаций»
 
Cyanobacteria 110107033006-phpapp01
Cyanobacteria 110107033006-phpapp01Cyanobacteria 110107033006-phpapp01
Cyanobacteria 110107033006-phpapp01
 
Othering theory presentation
Othering theory presentationOthering theory presentation
Othering theory presentation
 
More than a bandage for johnson & johnson's hcm
More than a bandage for johnson & johnson's hcmMore than a bandage for johnson & johnson's hcm
More than a bandage for johnson & johnson's hcm
 
Asuhan keperawatan tbc
Asuhan keperawatan tbcAsuhan keperawatan tbc
Asuhan keperawatan tbc
 
Seminar on olap online analytical
Seminar on olap  online analyticalSeminar on olap  online analytical
Seminar on olap online analytical
 

Similar to Hop ngu MIP

Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfNeed help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfactexerode
 
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfWhat is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfbadshetoms
 
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docxcs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docxmydrynan
 
Space Invaders Source Code
Space Invaders Source CodeSpace Invaders Source Code
Space Invaders Source CodeMitchell Strobel
 
Finish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdfFinish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdffasttrackcomputersol
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2osfameron
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perlgarux
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programmingkayalkarnan
 
Python Fundamentals - Basic
Python Fundamentals - BasicPython Fundamentals - Basic
Python Fundamentals - BasicWei-Yuan Chang
 
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)Dimitris Psounis
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionosfameron
 
C programs
C programsC programs
C programsMinu S
 
Community Panels: Pandora's Box or Panacea
Community Panels: Pandora's Box or PanaceaCommunity Panels: Pandora's Box or Panacea
Community Panels: Pandora's Box or Panaceavcuniversity
 
深入淺出C語言
深入淺出C語言深入淺出C語言
深入淺出C語言Simen Li
 

Similar to Hop ngu MIP (20)

Mips1
Mips1Mips1
Mips1
 
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfNeed help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
 
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfWhat is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
 
MIPS Merge Sort
MIPS Merge SortMIPS Merge Sort
MIPS Merge Sort
 
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docxcs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
 
Space Invaders Source Code
Space Invaders Source CodeSpace Invaders Source Code
Space Invaders Source Code
 
Finish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdfFinish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdf
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
TypeScript Go(es) Embedded
TypeScript Go(es) EmbeddedTypeScript Go(es) Embedded
TypeScript Go(es) Embedded
 
Pimp your data
Pimp your dataPimp your data
Pimp your data
 
Python Fundamentals - Basic
Python Fundamentals - BasicPython Fundamentals - Basic
Python Fundamentals - Basic
 
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 10 (ΕΚΤΥΠΩΣΗ)
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
C programs
C programsC programs
C programs
 
Community Panels: Pandora's Box or Panacea
Community Panels: Pandora's Box or PanaceaCommunity Panels: Pandora's Box or Panacea
Community Panels: Pandora's Box or Panacea
 
深入淺出C語言
深入淺出C語言深入淺出C語言
深入淺出C語言
 

Recently uploaded

FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoUXDXConf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024TopCSSGallery
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreelreely ones
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 

Recently uploaded (20)

FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 

Hop ngu MIP

  • 1. .data EnterA : .asciiz "Nhap A " EnterB : .asciiz "Nhap B " Menu : .asciiz "----------------------------Menu------------------------nn1. Tong a va bn2. Hieu a va bn3. Tich a va bn4. Thuong a va bn5. Kiem tra a va b la so nguyen to ?n6. Kiem tra a va b la so hoan thien ?n7. Kiem tra a va b la so chinh phuong ?n8. Kiem tra a va b la so doi xung ?n0. Thoatn--------------------------------------------------------------------n" Chose: .asciiz "Chon " Tong : .asciiz "Tong : " Hieu : .asciiz "Hieu : " Tich : .asciiz "Tich : " Thuong : .asciiz "Thuong : " Result : .asciiz "Ket qua: " True_Nt_A : .asciiz "A la so nguyen to" False_Nt_A : .asciiz "A khong phai so nguyen to" True_Nt_B : .asciiz "nB la so nguyen to" False_Nt_B : .asciiz "nB khong phai so nguyen to" True_Ht_A: False_Ht_A True_Ht_B: False_Ht_B .asciiz "A la so hoan thien" : .asciiz "A khong phai so hoan thien" .asciiz "nB la so hoan thien" : .asciiz "nB khong phai so hoan thien" True_Cp_A: False_Cp_A True_Cp_B: False_Cp_B .asciiz "A la so chinh phuong" : .asciiz "A khong phai so chinh phuong" .asciiz "nB la so chinh phuong" : .asciiz "nB khong phai so chinh phuong" True_Dx_A: False_Dx_A True_Dx_B: False_Dx_B .asciiz "A la so doi xung" : .asciiz "A khong phai so doi xung" .asciiz "nB la so doi xung" : .asciiz "nB khong phai so doi xung" .text .globl main main: li $v0,4 #print "Nhap a" la $a0,EnterA syscall li $v0,5 #scan a syscall move $s0,$v0 li $v0,4 #print "Nhap b" la $a0,EnterB syscall li $v0,5 #scan b syscall move $s1,$v0 li $v0,4 #print "Menu" la $a0,Menu syscall li $v0,4 #print "Chon"
  • 2. la $a0,Chose syscall li $v0,5 #scan k syscall move $s2,$v0 li $v0,4 #print "Ket qua : " la $a0,Result syscall addi $t0,$s2,-1 bne $t0,$0,Subtraction #k==0 Jump -> Exit add $s3,$s1,$s0 #S=a+b li $v0,4 #print "Tong : " la $a0,Tong syscall move $a0,$s3 li $v0,1 #print "Tong" syscall j Exit Subtraction: addi $t0,$s2,-2 bne $t0,$0,Multiplication sub $s3,$s0,$s1 #S=a-b li $v0,4 #print "Hieu : " la $a0,Hieu syscall move $a0,$s3 li $v0,1 #print Hieu syscall j Exit Multiplication: addi $t0,$s2,-3 bne $t0,$0,Division mult $s1,$s0 #S=a*b mflo $s3 li $v0,4 #print "Tich : " la $a0,Tich syscall move $a0,$s3 li $v0,1 #print Tich syscall j Exit Division: addi $t0,$s2,-4 bne $t0,$0,Prime div $s0,$s1 #S=a/b mflo $s3
  • 3. li $v0,4 #print "Thuong : " la $a0,Thuong syscall move $a0,$s3 li $v0,1 #print Thuong syscall Prime: addi $t0,$s2,-5 bne $t0,$0,CompleteNumber addi $s4,$0,2 #i=2 addi $s5,$0,1 #check = 1 Nt_A_Loop: slt $t0,$s4,$s0 #i<a i>=a thi thoat i<a beq $t0,$0,Nt_A_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat div $s0,$s4 # a%i mfhi $s6 #temp = a%i bne $s6,$0,Nt_A_ExitIf add $s5,$0,$0 j Nt_A_ExitLoop Nt_A_ExitIf: addi $s4,$s4,1 j Nt_A_Loop Nt_A_ExitLoop: bne $s5,$0,Nt_A_CheckIf li $v0,4 #print "A khong la so nguyen to " la $a0,False_Nt_A syscall j Nt_A_CheckElse Nt_A_CheckIf: li $v0,4 #print "A la so nguyen to " la $a0,True_Nt_A syscall Nt_A_CheckElse: addi $s4,$0,2 #i=2 addi $s5,$0,1 #check = 1 Nt_B_Loop: slt $t0,$s4,$s1 #i<a i>=a thi thoat i<a beq $t0,$0,Nt_B_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat div $s1,$s4 # a%i mfhi $s6 #temp = a%i bne $s6,$0,Nt_B_ExitIf add $s5,$0,$0 j Nt_B_ExitLoop
  • 4. Nt_B_ExitIf: addi $s4,$s4,1 j Nt_B_Loop Nt_B_ExitLoop: bne $s5,$0,Nt_B_CheckIf li $v0,4 #print "A khong la so nguyen to " la $a0,False_Nt_B syscall j Nt_B_CheckElse Nt_B_CheckIf: li $v0,4 #print "A la so nguyen to " la $a0,True_Nt_B syscall Nt_B_CheckElse: j Exit CompleteNumber: addi $t0,$s2,-6 bne $t0,$0,SquareNumber addi $s3,$0,0 #s=0 addi $s4,$0,1 #i = 1 Ht_A_Loop: slt $t0,$s4,$s0 #i<a i>=a thi thoat i<a beq $t0,$0,Ht_A_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat div $s0,$s4 # a%i mfhi $s6 #temp = a%i bne $s6,$0,Ht_A_ExitIf add $s3,$s3,$s4 Ht_A_ExitIf: addi $s4,$s4,1 j Ht_A_Loop Ht_A_ExitLoop: bne $s3,$s0,Ht_A_CheckIf li $v0,4 #print "A la so hoan thien" la $a0,True_Ht_A syscall j Ht_A_CheckElse Ht_A_CheckIf: li $v0,4 #print "A khong la so hoan thien" la $a0,False_Ht_A syscall Ht_A_CheckElse:
  • 5. addi $s3,$0,0 #s=0 addi $s4,$0,1 #i = 1 Ht_B_Loop: slt $t0,$s4,$s1 #i<a i>=a thi thoat i<a beq $t0,$0,Ht_B_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat div $s1,$s4 # a%i mfhi $s6 #temp = a%i bne $s6,$0,Ht_B_ExitIf add $s3,$s3,$s4 Ht_B_ExitIf: addi $s4,$s4,1 j Ht_B_Loop Ht_B_ExitLoop: bne $s3,$s1,Ht_B_CheckIf li $v0,4 #print "A la so hoan thien" la $a0,True_Ht_B syscall j Ht_B_CheckElse Ht_B_CheckIf: li $v0,4 #print "A khong la so hoan thien" la $a0,False_Ht_B syscall Ht_B_CheckElse: j Exit SquareNumber: addi $t0,$s2,-7 bne $t0,$0,SymmetryNumber addi $s5,$0,0 #check=0 addi $s4,$0,1 #i = 1 Cp_A_Loop: slt $t0,$s4,$s0 #i<a i>=a thi thoat i<a beq $t0,$0,Cp_A_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat mult $s4,$s4 # a*a mflo $s6 #temp = a*a bne $s6,$s0,Cp_A_ExitIf addi $s5,$0,1 #check=1 j Cp_A_ExitLoop Cp_A_ExitIf: addi $s4,$s4,1 j Cp_A_Loop
  • 6. Cp_A_ExitLoop: beq $s5,$0,Cp_A_CheckIf li $v0,4 #print "A la so hoan thien" la $a0,True_Cp_A syscall j Cp_A_CheckElse Cp_A_CheckIf: li $v0,4 #print "A khong la so hoan thien" la $a0,False_Cp_A syscall Cp_A_CheckElse: addi $s5,$0,0 #check=0 addi $s4,$0,1 #i = 1 Cp_B_Loop: slt $t0,$s4,$s1 #i<a i>=a thi thoat i<a beq $t0,$0,Cp_B_ExitLoop # Tuc la a khong lon hon i(a<=i) thi thoat mult $s4,$s4 # a*a mflo $s6 #temp = a*a bne $s6,$s1,Cp_B_ExitIf addi $s5,$0,1 #check=1 j Cp_B_ExitLoop Cp_B_ExitIf: addi $s4,$s4,1 j Cp_B_Loop Cp_B_ExitLoop: beq $s5,$0,Cp_B_CheckIf li $v0,4 #print "A la so hoan thien" la $a0,True_Cp_B syscall j Cp_B_CheckElse Cp_B_CheckIf: li $v0,4 #print "A khong la so hoan thien" la $a0,False_Cp_B syscall Cp_B_CheckElse: j Exit SymmetryNumber: addi $t0,$s2,-8 bne $t0,$0,Exit
  • 7. addi $s3,$0,0 #dao=0 add $s4,$s0,$0 #m=a Dx_A_Loop: slt $t0,$0,$s4 #0>=m thi 0, 0<m thi 1 beq $t0,$0,Dx_A_ExitLoop # 0<=m thi thoat addi $s7,$0,10 # $s7 = 10 mult $s3,$s7 # dao*10 mflo $s3 # dao=dao*10 div $s4,$s7 mfhi $s6 # temp = m % 10 add $s3,$s3,$s6 # dao = dao + temp div $s4,$s7 mflo $s4 j Dx_A_Loop Dx_A_ExitLoop: bne $s3,$s0,Dx_A_CheckIf li $v0,4 la $a0,True_Dx_A syscall j Dx_A_CheckElse Dx_A_CheckIf: li $v0,4 la $a0,False_Dx_A syscall Dx_A_CheckElse: addi $s3,$0,0 #dao=0 add $s4,$s1,$0 #m=a Dx_B_Loop: slt $t0,$0,$s4 #0>=m thi 0, 0<m thi 1 beq $t0,$0,Dx_B_ExitLoop # 0<=m thi thoat addi $s7,$0,10 # $s7 = 10 mult $s3,$s7 # dao*10 mflo $s3 # dao=dao*10 div $s4,$s7 mfhi $s6 # temp = m % 10 add $s3,$s3,$s6 # dao = dao + temp div $s4,$s7 mflo $s4 j Dx_B_Loop Dx_B_ExitLoop:
  • 8. bne $s3,$s1,Dx_B_CheckIf li $v0,4 la $a0,True_Dx_B syscall j Dx_B_CheckElse Dx_B_CheckIf: li $v0,4 la $a0,False_Dx_B syscall Dx_B_CheckElse: j Exit Exit: li $v0, 10 syscall