I am trying to write a code that asks the user to input a string, then displays the string with vowels removed.
Ex: Godzilla returns in 2014, the output will be 'Gdzll rtrns n 2014'
However, I am having massive difficutly in writing this for assembly. However, I was able to write a Java code that does the same thing. Could someone please, please help me be able to write this java code in MIPS assembly. I would be very grateful. Here's the code:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class RemoveVowels{
    public static void main(String []args) throws IOException{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

    System.out.println("Sample Program to Remove Vowels");
    System.out.println("from a given string \n");

    System.out.println("Enter a words : ");

    String s=in.readLine();

    System.out.println("\n" + "String with Vowels removed : ");

    String r=removeVowels(s);
    System.out.println(r);

    }

    private static String removeVowels(String s){

    String finalString="";

    for(int i=0;i<s.length(); i++) {

    if(!isVowel(Character.toLowerCase(s.charAt(i))))
    {
        finalString=finalString+s.charAt(i);
    }
    }
    return finalString;

    }

    private static boolean isVowel(char c) {

    String vowels="aeiou";

    for(int i=0; i<5; i++)
    {
        if(c==vowels.charAt(i))
        return true;
    }
    return false;

    }
    }

This is all I have for the assembly code. I already know how to prompt and read an input, and also how to use push/pop, it's just trying to get the code to read the vowels that I'm stuck at. Once I know that, then I can use the push and pop to remove the vowels and display the user input string without vowels. So far, all I have is:

     .data
    str:        .space 81   # buffer for input string
    strNV:      .space 81   # buffer for string w/o vowels
    prompt:     .asciiz "Enter a string up to 81 characters\n"
    head1:      .asciiz "\nOriginal String:  "
    head2:      .asciiz "\nNumber of vowels:  "
    head3:      .asciiz "\nWith vowels removed:  "

    .text   
    main:   
        #print the first prompt and get the input string from console
        li      $v0, 4          #load syscall value to print string into $v0
        la      $a0, prompt     #address of prompt to print
        syscall                 #print prompt to console
        li      $v0, 8          #load syscall value to read input string
        la      $a0, str        #addr of allocated space for input string is now in $a0
        li      $a1, 81
        syscall 

        jal     countVowel

        addi    $t1, $v0, 0     #the count of vowels is in $v0, save it into $t1
        li      $v0, 4          #print header then the count
        la      $a0, head1  
        syscall
        la      $a0, str        #print the original string
        syscall
        la      $a0, head2      #print second header before printing count
        syscall
        li      $v0, 1      
        addi    $a0, $t1, 0     #place the count in $a0
        syscall                 #print the count

        li      $v0, 4
        la      $a0, head3      #print the third header
        syscall
        la      $a0, strNV      #print string without vowels
        syscall


    End:    
        li      $v0, 10         #load syscall value for exit
        syscall                 #exit

I have made some headway on the code. I have it to where it now reads the vowels. The only problem is, after it removes the vowels, it only displays the letters in front of the first vowel it encounters. Such as when I type in 'RVB - Red Versus Blue', all it will displays is 'RVB - R'. What have I done wrong? I am getting the same thing on both the Mars and QTSpim simulators

.data
str:        .space 81   # buffer for input string
strNV:      .space 81   # buffer for string w/o vowels
prompt:     .asciiz "Enter a string up to 81 characters\n"
head1:      .asciiz "\nOriginal String:  "
head2:      .asciiz "\nNumber of vowels:  "
head3:      .asciiz "\nWith vowels removed:  "

.text   
main:   
    #print the first prompt and get the input string from console
    li      $v0, 4          #load syscall value to print string into $v0
    la      $a0, prompt     #address of prompt to print
    syscall                 #print prompt to console
    li      $v0, 8          #load syscall value to read input string
    la      $a0, str        #addr of allocated space for input string is now in $a0
    li      $a1, 81
    syscall 

    jal     countVowels

    addi    $t1, $v0, 0     #the count of spaces is in $v0, save it into $t1
    li      $v0, 4          #print header then the count
    la      $a0, head1  
    syscall
    la      $a0, str        #print the original string
    syscall
    la      $a0, head2      #print second header before printing count
    syscall
    li      $v0, 1      
    addi    $a0, $t1, 0     #place the count in $a0
    syscall                 #print the count

    li      $v0, 4
    la      $a0, head3      #print the third header
    syscall
    la      $a0, strNV      #print no spaces string
    li $v0, 4
    syscall


End:    
    li      $v0, 10         #load syscall value for exit
    syscall                 #exit

countVowels:
    la      $s0, strNV
    addi    $sp, $sp, 20   #adjust the stack pointer for saving
    sw      $s0, 8($sp)     #store addr of noviwek string
    sw      $ra, 4($sp)     #store return addr on the stack
    sw      $a0, 0($sp)     #store the count on the stack

    #Begin counting vowels
    addi    $t3, $a0, 0     #$t3 has addr of user input
    addi    $t5, $s0, 0     #$t5 has addr of string with no vowels
    li      $t6, 0          #$t6 holds index of string with no vowels 
    li      $t0, 0          #$t0 will hold the count of vowels
    li      $t4, 0          #$t4 holds the index of the string
loop:   
    add     $t1, $t3, $t4   #$t1 = addr of str[i]
    lb      $t2, 0($t1)     #$t2 = character in str[i]
    beq     $t2, 'a', exitCS  #break from loop if $t2 contains vowel character
    beq     $t2, 'e', exitCS  #break from loop if $t2 contains vowel character
    beq     $t2, 'i', exitCS  #break from loop if $t2 contains vowel character
    beq     $t2, 'o', exitCS  #break from loop if $t2 contains vowel character
    beq     $t2, 'u', exitCS  #break from loop if $t2 contains vowel character
    addi    $a0, $t2, 0     #place value to be checked in $a0

    #save values onto stack from temp registers to preserve them
    addi    $sp, $sp, -28   #adjust the stack pointer for 5 values
    sw      $t6, 24($sp)    #save index of string with no vowels
    sw      $t5, 20($sp)    #save addr of string with no vowels
    sw      $t4, 16($sp)    #save index of user input
    sw      $t3, 12($sp)    #save the addr of user input
    sb      $t2, 8($sp)     #save the character in str[i]
    sw      $t1, 4($sp)     #save the address of str[i] 
    sw      $t0, 0($sp)     #save the count of vowels

    jal     isVowel         #result from this jump and link will be in $v0 after call

    #pop saved values from the stack, then reset the pointer
    lw      $t6, 24($sp)
    lw      $t5, 20($sp)
    lw      $t4, 16($sp)
    lw      $t3, 12($sp)
    lb      $t2, 8($sp)
    lw      $t1, 4($sp)
    lw      $t0, 0($sp)
    addi    $sp, $sp, 28    #reset stack pointer
    beq     $v0, 'a', addTo   #if not a vowel, continue to next character
    beq     $v0, 'e', addTo   #if not a vowel, continue to next character
    beq     $v0, 'i', addTo   #if not a vowel, continue to next character
    beq     $v0, 'o', addTo   #if not a vowel, continue to next character
    beq     $v0, 'u', addTo   #if not a vowel, continue to next character
    addi    $t0, $t0, 1     #if it is a vowel, increment count
addTo:  
    beq     $v0, 'a', nextChar #If character is a space, branch
    beq     $v0, 'e', nextChar #If character is a space, branch
    beq     $v0, 'i', nextChar #If character is a space, branch
    beq     $v0, 'o', nextChar #If character is a space, branch
    beq     $v0, 'u', nextChar #If character is a space, branch
    move     $t7, $t6    #index if novowels string stores width of 4
    add     $t7, $t7, $t5   #now $t7 points at novowels[i]
    sb      $t2, 0($t7)     #store the character in the novowels string
    addi    $t6, $t6, 1     #increment the index of novowels

nextChar:

    addi    $t4, $t4, 1     #increment the index value
    j       loop            #jump back to loop and continue processing

exitCS:
    addi    $v0, $t0, 0     #count of vowels placed into $v0
    addi    $v1, $t5, 0
    lw      $ra, 4($sp)     #load return addr from the stack
    lw      $a0, 0($sp)     #load value to check from the stack
    addi    $sp, $sp, 8     #reset stack pointer
    jr      $ra             #return

isVowel:
    addi    $sp, $sp, -12   #adjust stack pointer to make room
    sw      $s0, 8($sp)
    sw      $ra, 4($sp)     #store value of return addr onto stack
    sw      $a0, 0($sp)     #store value to check onto stack

    #Check to see if the character is a space
    li      $t0, 97         #ascii value for 'a' character loaded into $t0
    li      $t0, 101        #ascii value for 'e' character loaded into $t0
    li      $t0, 105        #ascii value for 'i' character loaded into $t0
    li      $t0, 111        #ascii value for 'o' character loaded into $t0 
    li      $t0, 117        #ascii value for 'u' character loaded into $t0
    li      $v0, 0          #Set default return to 0, or "not a vowel character"
    bne     $t0, $a0, endSC #if ascii values match, character is a vowel
    li      $v0, 1          #$v0 = 1 means it is a vowel character

endSC:  
    lw      $s0, 8($sp)
    lw      $ra, 4($sp)     #restore return address
    lw      $a0, 0($sp)     #restore addr of str
    addi    $sp, $sp, 12    #reset the stack pointer

end:    jr $ra
This article has been dead for over six months. Start a new discussion instead.