SHARE
TWEET

Untitled

a guest Apr 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #=====NamNhuanGanNhat=====#
  2. #$a0 chua dia chi bien time
  3. #Dau thu tuc:
  4. NamNhuanGanNhat:
  5.     addi $sp,$sp,-20
  6.     #backup thanh ghi
  7.     sw $ra,($sp)
  8.     sw $s0,4($sp)
  9.     sw $s1,8($sp)
  10.     sw $t0,12($sp)
  11.     sw $t1,16($sp)
  12.  
  13. #Than thu tuc:
  14.     #Lay ra nam
  15.     jal Year
  16.     move $s0, $v0
  17.     move $t0, $v0
  18.     move $t1, $v0
  19.     #Kiem tra xem phai la nam nhuan khong
  20.     move $a0, $s0
  21.     jal KiemTraNamNhuan #Ket qua tra ve $v0
  22.     beq $v0,0,NamNhuanGanNhat.KoNhuan
  23.       #Nam hien tai la nam nhuan
  24.         move $t0,$s0
  25.         move $t1,$s0
  26.         j NamNhuanGanNhat.KT     
  27.       #Nam hien tai khong la nam nhuan
  28. NamNhuanGanNhat.KoNhuan:
  29.     #Tang nam hien tai len 1
  30.     addi $t1,$t1,1
  31.     #Kiem tra xem phai la nam nhuan khong
  32.     move $a0, $t1
  33.     jal KiemTraNamNhuan #Ket qua tra ve $v0
  34.     beq $v0,0,NamNhuanGanNhat.KoNhuan
  35.     move $v1,$t1
  36.     j NamNhuanGanNhat2
  37. NamNhuanGanNhat2:
  38.     #Giam nam hien tai len 1
  39.     addi $t0,$t0,-1
  40.     #Kiem tra xem phai la nam nhuan khong
  41.     move $a0, $t0
  42.     jal KiemTraNamNhuan #Ket qua tra ve $v0
  43.     beq $v0,0,NamNhuanGanNhat2
  44.     move $v0,$t0
  45.     sub $t0,$v1,$v0
  46.     ble $t0,8,TimNamGanNhat
  47.     j NamNhuanGanNhat.KT
  48. TimNamGanNhat:
  49.     sub $t1,$v1,$s0
  50.     sub $t0,$s0,$v0
  51.     beq $t0,$t1,NamNhuanGanNhat.KT
  52.     blt $t0,$t1,NhoGan
  53.     j LonGan
  54. NhoGan:
  55.     move $v1,$v0
  56.     subi $v0,$v0,4
  57.     j NamNhuanGanNhat.KT
  58. LonGan:
  59.     move $v0,$v1
  60.     addi $v1,$v1,4
  61.     j NamNhuanGanNhat.KT
  62.    
  63. NamNhuanGanNhat.KT:
  64. #Cuoi thu tuc
  65.     #restore thanh ghi
  66.     lw $ra,($sp)
  67.     lw $s0,4($sp)
  68.     lw $t0,8($sp)
  69.     lw $t1,12($sp)
  70.     #xoa stack
  71.     addi $sp,$sp,20
  72.     #tra ve
  73.     jr $ra
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top