Bài tập hợp ngữ MIPS 2
Số trang: 7
Loại file: pdf
Dung lượng: 132.50 KB
Lượt xem: 17
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Tham khảo tài liệu bài tập hợp ngữ mips 2, công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Bài tập hợp ngữ MIPS 2 Bài tập hợp ngữ MIPS 21. Nhập vào N số nguyên, lưu vào Stack. Xuất ra màn hình theo thứ tự ngượclại lúc nhập vào. Với N j begin_loop_1 end_loop_1: la $a0, text_2 #load text_2 string jal print_text move $s1, $s0 # $s1 = $s0 begin_loop_2: beq $s1, $zero, end_loop_2 # if (n==0) jump end_loop_2 jal stack_pop move $a0, $v0 jal print_int jal print_space addi $s1, $s1, -1 # n-- j begin_loop_2 end_loop_2: j end_programprint_text: li $v0, 4 #print text syscall jr $raread_int: li $v0, 5 #read interger syscall jr $raprint_int: li $v0, 1 #print interger syscall jr $raprint_space: addi $a0,$zero, 32 # $a0 = li $v0, 11 #print character syscall jr $rastack_push: addi $sp, $sp, -4 # $sp -=4 (new 4 byte in stack) sw $a0, 0($sp) #put a word to stack jr $rastack_pop: lw $v0, 0($sp) #get a word form stack addi $sp, $sp, 4 # $sp +=4 (free 4 byte in stack) jr $raend_program:Bài 2:.data text_1: .asciiz n = text_2: .asciiz Xuat ra: .textmain: la $a0, text_1 #load text_1 string jal print_text jal read_int move $s0, $v0 # n: $s0 la $a0, text_2 #load text_2 string jal print_text li $s1, 0 # $s1=0 begin_loop: beq $s0, $zero, end_loop # if (n==0) jump end_loop move $a0, $s1 jal print_int jal print_space addi $s1, $s1, 2 # $s1 += 2 addi $s0, $s0, -1 # n-- j begin_loop end_loop: j end_programprint_text: li $v0, 4 #print text syscall jr $raread_int: li $v0, 5 #read interger syscall jr $raprint_int: li $v0, 1 #print interger syscall jr $raprint_space: addi $a0,$zero, 32 # $a0 = li $v0, 11 #print character syscall jr $raend_program:Bài 3:.data text_1: .asciiz n = text_2: .asciiz Xuat ra: .textmain: la $a0, text_1 #load text_1 string jal print_text jal read_int move $s0, $v0 # n: $s0 move $s1, $s0 # $s1 = $s0 begin_loop_1: beq $s1, $zero, end_loop_1 # if (n==0) jump end_loop_1 jal read_int move $a0, $v0 jal stack_push addi $s1, $s1, -1 # n-- j begin_loop_1 end_loop_1: addi $a0, $zero, 1 move $a1, $s0 jal insert_sort la $a0, text_2 #load text_2 string jal print_text move $s1, $s0 # $s1 = $s0 begin_loop_2: beq $s1, $zero, end_loop_2 # if (n==0) jump end_loop_2 jal stack_pop move $a0, $v0 jal print_int jal print_space addi $s1, $s1, -1 # n-- j begin_loop_2 end_loop_2: j end_programprint_text: li $v0, 4 #print text syscall jr $raread_int: li $v0, 5 #read interger syscall jr $raprint_int: li $v0, 1 #print interger syscall jr $raprint_space: addi $a0,$zero, 32 # $a0 = li $v0, 11 #print character syscall jr $rastack_push: addi $sp, $sp, -4 # $sp -=4 (new 4 byte in stack) sw $a0, 0($sp) #put a word to stack jr $rastack_pop: lw $v0, 0($sp) #get a word form stack addi $sp, $sp, 4 # $sp +=4 (free 4 byte in stack) jr $rainsert_sort: #vitri=$a0 beq $a0, $a1, end_sort move $t0,$sp move $t1, $a0 begin_loop: beq $t1, $zero, end_loop addi $t0, $t0, 4 addi $t1, $t1, -1 j begin_loop end_loop: lw $t1,0($t0) # $t1=a[i] for: beq $t0, $sp, next lw $t2, -4($t0) # $t2=a[j-1] ble $t2, $t1, next sw $t2,0($t0) addi $t0, $t0, -4 j for next: sw $t1,0($t0) #a[j]=$t1 addi $a0, $a0, 1 j insert_sort end_sort: jr $raend_program:
Nội dung trích xuất từ tài liệu:
Bài tập hợp ngữ MIPS 2 Bài tập hợp ngữ MIPS 21. Nhập vào N số nguyên, lưu vào Stack. Xuất ra màn hình theo thứ tự ngượclại lúc nhập vào. Với N j begin_loop_1 end_loop_1: la $a0, text_2 #load text_2 string jal print_text move $s1, $s0 # $s1 = $s0 begin_loop_2: beq $s1, $zero, end_loop_2 # if (n==0) jump end_loop_2 jal stack_pop move $a0, $v0 jal print_int jal print_space addi $s1, $s1, -1 # n-- j begin_loop_2 end_loop_2: j end_programprint_text: li $v0, 4 #print text syscall jr $raread_int: li $v0, 5 #read interger syscall jr $raprint_int: li $v0, 1 #print interger syscall jr $raprint_space: addi $a0,$zero, 32 # $a0 = li $v0, 11 #print character syscall jr $rastack_push: addi $sp, $sp, -4 # $sp -=4 (new 4 byte in stack) sw $a0, 0($sp) #put a word to stack jr $rastack_pop: lw $v0, 0($sp) #get a word form stack addi $sp, $sp, 4 # $sp +=4 (free 4 byte in stack) jr $raend_program:Bài 2:.data text_1: .asciiz n = text_2: .asciiz Xuat ra: .textmain: la $a0, text_1 #load text_1 string jal print_text jal read_int move $s0, $v0 # n: $s0 la $a0, text_2 #load text_2 string jal print_text li $s1, 0 # $s1=0 begin_loop: beq $s0, $zero, end_loop # if (n==0) jump end_loop move $a0, $s1 jal print_int jal print_space addi $s1, $s1, 2 # $s1 += 2 addi $s0, $s0, -1 # n-- j begin_loop end_loop: j end_programprint_text: li $v0, 4 #print text syscall jr $raread_int: li $v0, 5 #read interger syscall jr $raprint_int: li $v0, 1 #print interger syscall jr $raprint_space: addi $a0,$zero, 32 # $a0 = li $v0, 11 #print character syscall jr $raend_program:Bài 3:.data text_1: .asciiz n = text_2: .asciiz Xuat ra: .textmain: la $a0, text_1 #load text_1 string jal print_text jal read_int move $s0, $v0 # n: $s0 move $s1, $s0 # $s1 = $s0 begin_loop_1: beq $s1, $zero, end_loop_1 # if (n==0) jump end_loop_1 jal read_int move $a0, $v0 jal stack_push addi $s1, $s1, -1 # n-- j begin_loop_1 end_loop_1: addi $a0, $zero, 1 move $a1, $s0 jal insert_sort la $a0, text_2 #load text_2 string jal print_text move $s1, $s0 # $s1 = $s0 begin_loop_2: beq $s1, $zero, end_loop_2 # if (n==0) jump end_loop_2 jal stack_pop move $a0, $v0 jal print_int jal print_space addi $s1, $s1, -1 # n-- j begin_loop_2 end_loop_2: j end_programprint_text: li $v0, 4 #print text syscall jr $raread_int: li $v0, 5 #read interger syscall jr $raprint_int: li $v0, 1 #print interger syscall jr $raprint_space: addi $a0,$zero, 32 # $a0 = li $v0, 11 #print character syscall jr $rastack_push: addi $sp, $sp, -4 # $sp -=4 (new 4 byte in stack) sw $a0, 0($sp) #put a word to stack jr $rastack_pop: lw $v0, 0($sp) #get a word form stack addi $sp, $sp, 4 # $sp +=4 (free 4 byte in stack) jr $rainsert_sort: #vitri=$a0 beq $a0, $a1, end_sort move $t0,$sp move $t1, $a0 begin_loop: beq $t1, $zero, end_loop addi $t0, $t0, 4 addi $t1, $t1, -1 j begin_loop end_loop: lw $t1,0($t0) # $t1=a[i] for: beq $t0, $sp, next lw $t2, -4($t0) # $t2=a[j-1] ble $t2, $t1, next sw $t2,0($t0) addi $t0, $t0, -4 j for next: sw $t1,0($t0) #a[j]=$t1 addi $a0, $a0, 1 j insert_sort end_sort: jr $raend_program:
Tìm kiếm theo từ khóa liên quan:
Công nghệ thông tin cấu trúc dữ liệu lý thuyết đồ thị Javascript ASP.NET Tin học đại cương giáo trình Tin học đại cương bài giảng Tin học đại cương tài liệu Tin học đại cương lý thuyết Tin học đại cươngTài liệu có liên quan:
-
52 trang 467 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 366 0 0 -
Đề cương chi tiết học phần Cấu trúc dữ liệu và giải thuật (Data structures and algorithms)
10 trang 360 0 0 -
96 trang 334 0 0
-
74 trang 329 0 0
-
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 319 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 319 1 0 -
Ứng dụng công cụ Quizizz thiết kế trò chơi học tập trong giảng dạy học phần tin học đại cương
12 trang 310 0 0 -
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 304 0 0 -
Tài liệu hướng dẫn sử dụng thư điện tử tài nguyên và môi trường
72 trang 301 0 0