assembly - How do I count the number of characters entered using MIPS? -
i prompt user enter string of 40 characters. how count how many characters user entered? count each character, need store count of digits, uppercase , lowercase letters, spaces, , other characters. how should recognize difference between these types of characters?
.text # beginning of code .globl main # beginning of main main: # main procedure li $v0, 4 # print_string service number la $a0, prompt00 # load address of prompt syscall # print prompt li $v0, 8 # read_string service number la $a0, buffer # load address of buffer la $a1, 40 # max length of 40 syscall # read_string li $v0, 4 # print_string service number la $a0, buffer # load address of buffer syscall # print buffer li $v0, 10 # using service 10, terminate syscall # terminate .data # beginning of data area buffer: # container input string .space 40 # max length of 40 characters newline: # variable represent newline .asciiz "\n" # newline character prompt00: .asciiz "enter 40 characters: "
you can check see if character in register looking @ falls within of applicable ranges: ascii values table.
strings should stored null character '\0' @ end, can find length.
Comments
Post a Comment