Question

how do i take input from user that gives first and last name and flip it...

how do i take input from user that gives first and last name and flip it to display last, first in mips assembly language? please need help. looking through this mips book to get anything.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

--------------------------------------------------------

Program

#Data declaration part
.data
input: .asciiz "Enter your name:"
nameInput: .asciiz
#Program starts here
.text
#Prompt for name
li $v0,4
la $a0,input
syscall
#Read name and store in nameInput
li $v0,8
la $a0,nameInput
li $a1,1024
syscall
#Get address of name storage space
la $t0,nameInput
#Loop to find space
loop:
lb $a0,($t0)
beq $a0,32,next
addi $t0,$t0,1
j loop
#If space encounter then came here then next letter is the
#starting character of last name
next:
    addi $t0,$t0,1
    #Loop to read until \n and print character by character
printLastName:
   lb $a0,($t0)
   beq $a0,10,printFirstName
   li $v0,11
   syscall
addi $t0,$t0,1
j printLastName
#For first name print
printFirstName:
   #Get starting address of the name storage
   la $t0,nameInput
   #Display comma
   li $v0,11
   li $a0,44
   syscall
   #Display space
   li $v0,11
   li $a0,32
   syscall
   #Loop to print first name,means until space
loop2:
    lb $a0,($t0)
    beq $a0,32,exit
    li $v0,11
   syscall
addi $t0,$t0,1
j loop2
#End of the program
exit:
li $v0,10
syscall

-----------------------------------------------

Output

Enter your name:Charlie Gomaz
Gomaz, Charlie
-- program is finished running --

Add a comment
Know the answer?
Add Answer to:
how do i take input from user that gives first and last name and flip it...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in Mips how do i get a input string from a user and then print it...

    in Mips how do i get a input string from a user and then print it to the screen? for example if a user enters A6B4GYJx how do i get that and then print it to the screen?

  • Class name: "NextSquare" Prompt the user to enter an integer. display your name and the next...

    Class name: "NextSquare" Prompt the user to enter an integer. display your name and the next integer larger than the input integer which is a perfect square. for example, if the input is 7, the output should be (your name plus) 9. I am looking for help with this and need the answer to be in JOptionPane with java language.

  • Write a MARIE program to allow the user to input eight integers (positive, negative, or zero)...

    Write a MARIE program to allow the user to input eight integers (positive, negative, or zero) and then find the smallest and the largest and print each of these out. Please I need this program in MIPS language. ASSEMBLY language. Thank you

  • how to delete first word and last word in a string of user input ex: int...

    how to delete first word and last word in a string of user input ex: int main) string fullname; cout << "Enter Full Name ex: Rob John Smith" << endl; cin >fullname; //Some code that will delete the first and /last name to get middle name cout < "Your middle name is:" midname;

  • How do I write a program in MIPs assembly that will take 2 words from the...

    How do I write a program in MIPs assembly that will take 2 words from the user and check if they're in a string. For example: String: " A B Cat C Dog D E Cat cAT Owl Ferret" User input: Word 1: Owl Word 2: Cat OUTPUT: Owl- 1 time(s) Cat: 3 time(s) Owl- # Cat-###

  • Lab: User login system (python) Create a user login system. Your code should do the following:...

    Lab: User login system (python) Create a user login system. Your code should do the following: 1.Load your user database from “UD.txt” (USE THE EXACT FILE NAME, file is given in the folder) 2.Display “Login or create a new user? Select L to login, select C to create new user.” 3. If wrong selection is entered, take the user back to step 2. 4. If the user entered “L”, display “Please enter your user name and hit enter” 5. Check...

  • I need to create a code based off of what the users first name and last...

    I need to create a code based off of what the users first name and last name are along with a random set of numbers no longer than 10 characters as the picture below demonstrate (Java language) Scenario: You have been appointed by the CS department to create a username generator to create CS email accounts automatically. The CS email will have the following format: Username@cs.utep.du. Your username must have a limit of 10 characters. Your program, will provide three...

  • (Java) HELP! Create a program that will ask the user to enter their first name and...

    (Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...

  • I need to be able to input first and last name. My code only outputs first...

    I need to be able to input first and last name. My code only outputs first when you put 2 names. This is not my full code. Any type of help wou;d be great! int main() { int main_choice; int grade_choice; int std_id; int new_grade; char g_name[100]; char s_name[100]; float a,b,c; gradebook g; do { cout <<endl; cout<< " -=| MAIN MENU |=-" << endl; cout<< "1. Add a student" << endl; cout << "2. Remove a student" << endl;...

  • Design a modular program using pseudo-code which prompts a user for their first name, followed by...

    Design a modular program using pseudo-code which prompts a user for their first name, followed by their last name; then displays a "Hello" salutation which concatenates their first name with their last name. Sample output (user input shown in red): Please enter your first name: John Please enter your last name: Smith Hello, John Smith! Your program must include a main module and one function; this function prompts the user for either their first name or last name, using a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT