.data table: # Complete the table as specified in the lab. The null character has # been set for you. (ASCII values range from 0 to 127 base 10.) .byte 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 .byte 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 line: .byte 0:80 # up to an 80-character input line prompt: .asciiz "Please type a line with fewer than 80 characters." not_found_msg: .asciiz "Line was all whitespace." alphnum_msg: .asciiz "First nonwhitespace character is alphanumeric: " other_msg: .asciiz "First nonwhitespace character is not alphanumeric: " .text main: la $a0,prompt # Print the prompt jal puts li $a0,0x0A # And a newline jal putc la $a0,line # read a line li $a1,80 jal gets la $s1,line la $s2,table # The scan code takes a pointer to a character in $s1 # and the address of a translation table in $s2. It increments $s1 # to point to the first subsequent character whose table entry is nonzero, # and stores the corresponding table value in $v0. scan: # Your scan code from part B of exercise 1 goes here # please take note of the comments immediately before # the scan label. Jump/Branch to scan_done when your # loop terminates. scan_done: li $t0,1 bne $t0,$v0,nws_found la $a0,not_found_msg # Print not found message jal puts li $a0,0x0A # And newline jal putc j exit # Return from main nws_found: # scan hit a nonwhitespace character li $t0,2 bne $t0,$v0,other_found la $a0,alphnum_msg # scan hit an alphanumeric character jal puts lbu $a0,0($s1) # Mention which one jal putc li $a0,0x0A # And newline jal putc j exit # Return from main other_found: # scan hit a nonalphanumeric character la $a0,other_msg # Print message jal puts lbu $a0,0($s1) # Mention which one jal putc li $a0,0x0A # And newline jal putc j exit # Return from main putc: addi $sp,$sp,-4 sw $ra,0($sp) # just in case syscall screws up $ra li $v0,11 # syscall code for printing a character syscall lw $ra,0($sp) addi $sp,$sp,4 jr $ra puts: addi $sp,$sp,-4 sw $ra,0($sp) # just in case syscall screws up $ra li $v0,4 # syscall code for printing a character syscall lw $ra,0($sp) addi $sp,$sp,4 jr $ra gets: addi $sp,$sp,-4 sw $ra,0($sp) # just in case syscall screws up $ra li $v0,8 # syscall code for printing a character syscall lw $ra,0($sp) addi $sp,$sp,4 jr $ra exit: li $v0,10 syscall