- #1
Sasha7440
- 1
- 0
MIPS -- write a function to remove blanks
So I am new to MIPS and I have been working on a program that my brother had for a class a while back ago and I am trying to do the following...
Write a function RemoveBlanks() that inputs an asciz string
consisting of a list of words. The function returns the
string with all extra blanks removed; e.g there should be
only 1 blank separating words.
Examples:
input "the fat dog ate my sandwich \0"
output "the fat dog ate my sandwich\0"
input " where is my hat\0"
output "where is my hat\0"
There is only argument to the function - the array of characters
that is the string. The result modifies the original string.
e.g the call in c would be void RemoveBanks ( char A[] );
I also want to continue by writing the following...
Write a function getAlpha() to input a string from the keyboard.
Any chars that are not alphabetic (a-z or A-Z) or blanks are replaced
with blanks in the string.
void getAlpha( char A[] , int N)
Examples:
input from keyboard " where 45 to me 789 Joe%"
output " where to me Joe\0"
Read the string 1 char at a time. (Use the read character syscall.)
Use a special char of % as a flag to denote the end of the input
string. Replace it with a \0 in the output string.
Read a maximum of N chars into the array ( including the \0 )
Then last the main function...
Write a main program that reads in a string from the keyboard
using getAlpha(), prints the string, uses RemoveBanks()
to remove extra blanks and then prints the resulting
string.
Clearly identify each function in the source code. Test the
code on the keyboard input:
" 34 big 45old 674;jack%" (without the " "s)
***** If anyone ould be willing to send me advise or code to look at that would be great! So far I have been able to take some instruction on how to set up the stack and to tear it back down and how to call the system to enter the string. here is what I have ...
.globl removeBlanks
.text
removeBlanks:
sw $ra, -4
sw $fp, -8
move $fp, $sp
addiu $sp, $sp, -8
addi $v0, $0, 8
syscall
** HELP HERE PLEASE***
setBack:
move $sp, $fp
lw $ra, -4($sp)
lw $fp, -8($sp)
jr $ra
Thanks so much!
So I am new to MIPS and I have been working on a program that my brother had for a class a while back ago and I am trying to do the following...
Write a function RemoveBlanks() that inputs an asciz string
consisting of a list of words. The function returns the
string with all extra blanks removed; e.g there should be
only 1 blank separating words.
Examples:
input "the fat dog ate my sandwich \0"
output "the fat dog ate my sandwich\0"
input " where is my hat\0"
output "where is my hat\0"
There is only argument to the function - the array of characters
that is the string. The result modifies the original string.
e.g the call in c would be void RemoveBanks ( char A[] );
I also want to continue by writing the following...
Write a function getAlpha() to input a string from the keyboard.
Any chars that are not alphabetic (a-z or A-Z) or blanks are replaced
with blanks in the string.
void getAlpha( char A[] , int N)
Examples:
input from keyboard " where 45 to me 789 Joe%"
output " where to me Joe\0"
Read the string 1 char at a time. (Use the read character syscall.)
Use a special char of % as a flag to denote the end of the input
string. Replace it with a \0 in the output string.
Read a maximum of N chars into the array ( including the \0 )
Then last the main function...
Write a main program that reads in a string from the keyboard
using getAlpha(), prints the string, uses RemoveBanks()
to remove extra blanks and then prints the resulting
string.
Clearly identify each function in the source code. Test the
code on the keyboard input:
" 34 big 45old 674;jack%" (without the " "s)
***** If anyone ould be willing to send me advise or code to look at that would be great! So far I have been able to take some instruction on how to set up the stack and to tear it back down and how to call the system to enter the string. here is what I have ...
.globl removeBlanks
.text
removeBlanks:
sw $ra, -4
sw $fp, -8
move $fp, $sp
addiu $sp, $sp, -8
addi $v0, $0, 8
syscall
** HELP HERE PLEASE***
setBack:
move $sp, $fp
lw $ra, -4($sp)
lw $fp, -8($sp)
jr $ra
Thanks so much!