Hello everyone, I'm trying to create a program that will accept a string and output how many characters are in that string. The input can be a mixture of upper/lowercase letters, digits, spaces, and other cases such as .%^& etc.
This is my first time use any type of assembly language so please understand if I have trouble
This is what I have so far, the only thing it does right now is just output what I input, so if I input '"hello" the output will be "hello". Thanks for your help.
.data
Q1:
.asciiz "Please enter a string that is up to eighty characters: "
ans1:
.asciiz "\nThe length of the string you entered contains this many characters: "
buffer: .space 80 # create space for string input
.text
.globl main #must be global
main:
li $v0, 4 # system call code for print_str
la $a0, Q1 # address of string to print
syscall # print the Q1
li $v0, 8 # code for syscall read_string
la $a0, buffer # tell syscall where the buffer is
li $a1, 80 # tell syscall how big the buffer is
syscall
li $v0, 8 # code for syscall read_string
la $t0, buffer # place address of buffer in $t0
lb $t1, 0($t0) # read byte located at address in $t0
addi $t0, $t0, 0 # increment address in $t0
#sbrk $a0, 9 # the amount of how long the string is from the address
li $v0, 4
la $a0, ans1
syscall
li $v0, 4
move $a0, $t0
syscall
jr $ra # return to system