Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Implements nCr function
- .data
- intro: .asciiz "We will calculate the combination formula nCr = n! / ((n-r)! * r! \n"
- req_n: .asciiz "Please enter the number of items in a set 'n': "
- req_r: .asciiz "Now enter the size of each combinatoric subset 'r': "
- error: .asciiz "\nError: Your value of 'n' must be greater than 'r', please retry\n"
- success: .asciiz "Debug Complete"
- .text
- la $a0, intro
- li $v0, 4
- syscall
- input:
- la $a0, req_n
- li $v0, 4
- syscall
- li $v0, 5
- syscall
- move $s0, $v0
- la $a0, req_r
- li $v0, 4
- syscall
- li $v0, 5
- syscall
- move $s1, $v0
- ble $s0, $s1, exception
- la $a0, success
- li $v0, 4
- syscall
- li $v0, 10
- syscall
- exception:
- la $a0, error
- li $v0, 4
- syscall
- j input
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement