SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

Báo cáo kĩ thuật phần mềm và ứng dụng
Báo cáo kĩ thuật phần mềm và ứng dụngBáo cáo kĩ thuật phần mềm và ứng dụng
Báo cáo kĩ thuật phần mềm và ứng dụng
Vượng Đặ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
Cao Toa
 
Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...
Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...
Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...
Chien Dang
 

Mais procurados (20)

Báo cáo kĩ thuật phần mềm và ứng dụng
Báo cáo kĩ thuật phần mềm và ứng dụngBáo cáo kĩ thuật phần mềm và ứng dụng
Báo cáo kĩ thuật phần mềm và ứng dụng
 
Hop ngu mips
Hop ngu mipsHop ngu mips
Hop ngu mips
 
Kiến trúc máy tính và hợp ngữ bài 07
Kiến trúc máy tính và hợp ngữ bài 07Kiến trúc máy tính và hợp ngữ bài 07
Kiến trúc máy tính và hợp ngữ bài 07
 
[Cntt] bài giảng kĩ thuật vi xử lí
[Cntt] bài giảng kĩ thuật vi xử lí[Cntt] bài giảng kĩ thuật vi xử lí
[Cntt] bài giảng kĩ thuật vi xử lí
 
Ktmt chuong 5
Ktmt chuong 5Ktmt chuong 5
Ktmt chuong 5
 
Bài 6: Thiết kế cơ sở dữ liệu - Giáo trình FPT
Bài 6: Thiết kế cơ sở dữ liệu - Giáo trình FPTBài 6: Thiết kế cơ sở dữ liệu - Giáo trình FPT
Bài 6: Thiết kế cơ sở dữ liệu - Giáo trình FPT
 
Chuong 04 mach logic
Chuong 04 mach logicChuong 04 mach logic
Chuong 04 mach logic
 
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
 
đề thi java ptit
đề thi java ptitđề thi java ptit
đề thi java ptit
 
Ket tap, ke thua
Ket tap, ke thuaKet tap, ke thua
Ket tap, ke thua
 
Quy tắc thiết kế giao diện và viết code C#
Quy tắc thiết kế giao diện và viết code C#Quy tắc thiết kế giao diện và viết code C#
Quy tắc thiết kế giao diện và viết code C#
 
Slide chuong4
Slide chuong4Slide chuong4
Slide chuong4
 
Bài giảng công nghệ phần mềm PTIT
Bài giảng công nghệ phần mềm PTITBài giảng công nghệ phần mềm PTIT
Bài giảng công nghệ phần mềm PTIT
 
Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...
Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...
Tính toán khoa học - Chương 6: Bài toán giá trị ban đầu với phương trình vi p...
 
Đề thi Kỹ thuật lập trình có lời giải
Đề thi Kỹ thuật lập trình có lời giảiĐề thi Kỹ thuật lập trình có lời giải
Đề thi Kỹ thuật lập trình có lời giải
 
12.ma trận và dịnh thức
12.ma trận và dịnh thức12.ma trận và dịnh thức
12.ma trận và dịnh thức
 
Mẫu báo cáo bài tập lớn
Mẫu báo cáo bài tập lớnMẫu báo cáo bài tập lớn
Mẫu báo cáo bài tập lớn
 
Tóm tắt về track, sector, cluster, cylinder
Tóm tắt về track, sector, cluster, cylinderTóm tắt về track, sector, cluster, cylinder
Tóm tắt về track, sector, cluster, cylinder
 
Phân tích và thiết kế hệ thống quản lý bán hàng
Phân tích và thiết kế hệ thống quản lý bán hàngPhân tích và thiết kế hệ thống quản lý bán hàng
Phân tích và thiết kế hệ thống quản lý bán hàng
 
Chuẩn hóa lược đồ quan hệ
Chuẩn hóa lược đồ quan hệChuẩn hóa lược đồ quan hệ
Chuẩn hóa lược đồ quan hệ
 

Destaque

lap trinh assembly cho VXL
lap trinh  assembly cho VXLlap trinh  assembly cho VXL
lap trinh assembly cho VXL
Thâ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 8086
onlylove511
 
Chuong 4. lap trinh hop ngu
Chuong 4. lap trinh hop nguChuong 4. lap trinh hop ngu
Chuong 4. lap trinh hop ngu
mituan
 
Exercicios lista05 hiperestaticas
Exercicios lista05 hiperestaticasExercicios lista05 hiperestaticas
Exercicios lista05 hiperestaticas
Douglas Roberto
 
Silladeruedas
SilladeruedasSilladeruedas
Silladeruedas
silva9703
 
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
DaniChacon98
 
Cyanobacteria 110107033006-phpapp01
Cyanobacteria 110107033006-phpapp01Cyanobacteria 110107033006-phpapp01
Cyanobacteria 110107033006-phpapp01
shamsudin DrGez
 
Othering theory presentation
Othering theory presentationOthering theory presentation
Othering theory presentation
Sal9594
 

Destaque (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
 
Chuong 4. lap trinh hop ngu
Chuong 4. lap trinh hop nguChuong 4. lap trinh hop ngu
Chuong 4. lap trinh hop ngu
 
Bài giảng Assembly
Bài giảng AssemblyBài giảng Assembly
Bài giảng Assembly
 
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
 

Semelhante a 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.pdf
actexerode
 
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
mydrynan
 
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
fasttrackcomputersol
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
kayalkarnan
 
C programs
C programsC programs
C programs
Minu 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 Panacea
vcuniversity
 

Semelhante a 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語言
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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