###################################################################### # Tom Kelliher, CS 220 # # postfixHints.spim - This file contains the frame-based MIPS code for # the C library functions isdigit(), isspace(), and exit(). This is # NOT an executable MIPS program. ###################################################################### ###################################################################### # isdigit - decimal-digit character test. The argument should be in # $a0. The test value will be returned through $v0. Returns 1 # if the argument is one of ASCII 0 through 9; otherwise returns 0. ###################################################################### .text .globl isdigit isdigit: sub $sp, $sp, 8 sw $fp, 8($sp) sw $ra, 4($sp) add $fp, $sp, 8 li $v0, 0 blt $a0, '0', isdigit_eif1 bgt $a0, '9', isdigit_eif1 li $v0, 1 isdigit_eif1: lw $ra, 4($sp) lw $fp, 8($sp) add $sp, $sp, 8 jr $ra ###################################################################### # isspace - white-space character test. return 1 through $v0 if $a0 # contains one of the typical white-space characters: space, tab, # or new line. Otherwise return 0. ###################################################################### .text .globl isspace isspace: sub $sp, $sp, 8 sw $fp, 8($sp) sw $ra, 4($sp) add $fp, $sp, 8 li $v0, 1 beq $a0, ' ', isspace_eif1 beq $a0, 9, isspace_eif1 # Horizontal tab. beq $a0, 10, isspace_eif1 # New line. li $v0, 0 isspace_eif1: lw $ra, 4($sp) lw $fp, 8($sp) add $sp, $sp, 8 jr $ra ###################################################################### # exit - Terminate program execution. ###################################################################### .text .globl exit exit: li $v0, 10 syscall