Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Implements nCr function
  2.  
  3. .data
  4. intro: .asciiz "We will calculate the combination formula nCr = n! / ((n-r)! * r! \n"
  5. req_n: .asciiz "Please enter the number of items in a set 'n': "
  6. req_r: .asciiz "Now enter the size of each combinatoric subset 'r': "
  7. error: .asciiz "\nError: Your value of 'n' must be greater than 'r', please retry\n"
  8. success: .asciiz "Debug Complete"
  9.  
  10. .text
  11. la $a0, intro
  12. li $v0, 4
  13. syscall
  14.  
  15. input:
  16. la $a0, req_n
  17. li $v0, 4
  18. syscall
  19. li $v0, 5
  20. syscall
  21. move $s0, $v0
  22.  
  23. la $a0, req_r
  24. li $v0, 4
  25. syscall
  26. li $v0, 5
  27. syscall
  28. move $s1, $v0
  29.  
  30. ble $s0, $s1, exception
  31.  
  32. la $a0, success
  33. li $v0, 4
  34. syscall
  35. li $v0, 10
  36. syscall
  37.  
  38. exception:
  39. la $a0, error
  40. li $v0, 4
  41. syscall
  42. j input
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement