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.

  • 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;

  • 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: [email protected]. Your username must have a limit of 10 characters. Your program, will provide three...

  • 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...

  • Need Java help: 1. Create a Java program that accepts input String input from a user...

    Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.

  • In Java, How would I create a program that does this from user input? studentld: consists...

    In Java, How would I create a program that does this from user input? studentld: consists of the first two characters of the student's first name, student's birth year, and the last two characters of the last name. For instance, if the student's full name is John mith and birthyear is 1988, then the studentid will be jo1988th. s email: consists of the first name, dot, last name, and @pa2.com. For instance, if the student's full name is John Smith,...

  • C++ Do not use "cin" to get the names from the user. Use "getline()". Name Arranger...

    C++ Do not use "cin" to get the names from the user. Use "getline()". Name Arranger Write a program that asks for the user’s first, middle, and last names. The names should be stored in three different character arrays. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example,...

  • I need help with MIPS-32 assembly language. My question is how to open an existing text...

    I need help with MIPS-32 assembly language. My question is how to open an existing text file, read from the file, display contents, and close the file read in MIPS32 using MARS 4.5 MIPS simulator. Existing text file is testfile.txt testfile.txt contains: 001010100101001100

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
ADVERTISEMENT