CPS 104 (Ramm) Fall Semester 1995 Homework Assignment #4 Due Monday, Oct. 2 Write an assembler subroutine designed to read in a decimal number from the keyboard. Call this subroutine decin and have it work in the following way. It should read in a string from the keyboard using system call code 8. It should then go through that (null terminated) string a character (byte) at a time until it encounters the first valid decimal character(digit). All non-decimal characters up to that point should be ignored. Once it finds decimal characters, it should start converting these to an integer until another non-decimal character is read in. Then it should return the value of this number in the $v0 register. If the number being read in is too large for the register, your program should go blindly ahead, keeping only the 32 least significant bits of the number entered. To show that your program is working, call decin in a loop, following each call to decin with a call to the integer output system call (code 1) to show that the value was properly read in and converted. Have the program exit the loop when a value of zero is returned by decin. It is good programming practice to have subroutines save registers on entry to the subroutine and to restore these when the subroutine exits. Support the convention specified in the table on page 10 of your SPIM manual. It is unnecessary (and inefficient) to save registers that are not altered in the subroutine. In this assignment and in future assignments, subroutines which do not follow this practice of saving and restoring the appropriate environment will be counted in error, unless a strong, written case is made (in the comments, for example) for not saving register, etc. September 22, 1995