# Starter file for ex2.asm .data input1: .space 22 input2: .space 22 ... .text main: ... ... #----------------------------------------------------------------# # Write code here to do exactly what main does in the C program. # # Please follow these guidelines: # # Use syscall 8 to do the job of fgets() # Then call h_to_i to perform conversion from hex string to integer # Then call NchooseK to compute its factorial # Then use syscall 1 to print the factorial result #----------------------------------------------------------------# ... ... end: ori $v0, $0, 10 # system call 10 for exit syscall # we are out of here. h_to_i: #----------------------------------------------------------------# # $a0 has address of the string to be parsed. # # Write code here to implement the function you wrote in C. # Since this is a leaf procedure, you may be able to get away # without using the stack at all. # # $v0 should have the integer result to be returned to main. #----------------------------------------------------------------# ... ... jr $ra NchooseK: #----------------------------------------------------------------# # $a0 has the number n, $a1 has k, from which to compute n choose k # # Write code here to implement the function you wrote in C. # Your implementation need NOT be recursive; a simple iterative # implementation is sufficient. Hence, this may be a leaf # procedure, and you may be able to get away without using the # stack at all. # # $v0 should have the NchooseK result to be returned to main. #----------------------------------------------------------------# ... ... jr $ra