Question

If a user inputs a string, what is the correct way to iterate through the string...

If a user inputs a string, what is the correct way to iterate through the string in MIPS assembly? Please use comments.

Homework Answers

Answer #1

My encryption method is as follows:

encryptMessage:
    la $s0, message     #s0 will hold message that will be iterated through
    lw $t1, key     #s1 will hold the key to shift by
    li $t0, 0       #t0 will be iterator, starting at 0

encryptionLoop:
    add $s1, $s0, $t0   #$s1 = message[i]
    lb $s2, 0($s1)      #Loading char to shift into $s2
    beq $s2, $zero, exit    #Breaking the loop if we've reached the end: http://stackoverflow.com/questions/12739463/how-to-iterate-a-string-in-mips-assembly
    add $s2, $s2, $t1   #Shifting the character by the key amount
    la $s1, ($s2)       #Changing the character in message to the shifted character
    addi $t0, $t0, 1    #i++
    j encryptionLoop    #Going back to the beginning of the loop
Know the answer?
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
Similar Questions
Using MIPS, create a stack that takes user input until the user inputs 0, then output...
Using MIPS, create a stack that takes user input until the user inputs 0, then output the characters that were entered onto the stack. Make sure to use $sp. Example: Please enter a number. Press 0 to quit: 4 5 2 5 7 0 Your numbers were: 4 5 2 5 7
In MIPS only!! make a program that multiplies a user input by 15. YOU CAN ONLY...
In MIPS only!! make a program that multiplies a user input by 15. YOU CAN ONLY USE ADDITION AND BITSHIFT OPERATIONS. Also very important, make sure its correct by using the mult and mflo operators (!More Important, explain to me how that's done!) . make sure to display user input and display the output. !!!please put comments on each line of what's happening!!!
Create a function in MIPS using MARS to determine whether a user input string is a...
Create a function in MIPS using MARS to determine whether a user input string is a palindrome or not. Assume that the function is not part of the same program that is calling it. This means it would not have access to your .data segment in the function, so you need to send and receive information from the function itself. The program should be as simple as possible while still using necessary procedures. Follow the instructions below carefully. Instructions: ●...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to the characters that are in the string until they are ready to stop. We will need to read in several pieces of data from the user, including a string and multiple characters. You can set a maximum size for the user string, however, the specific size of the string can change and you can’t ask them how long the string is (see the sample...
Write an assembly program which asks user to enter a character from ‘A’ to ‘Z’. If...
Write an assembly program which asks user to enter a character from ‘A’ to ‘Z’. If the user enters any other character, the program asks user to enter the character again. In this way the program inputs 300 characters and stores it in memory location from address $1000 to $112B. Hint: Use CPU register Y as counter
As urine passes through the collecting system on its way to the bladder, what is the...
As urine passes through the collecting system on its way to the bladder, what is the correct order of structures that it passes through? Minor calyx ________________________________________________________________ ________________________________________________________________ ________________________________________________________________ Bladder What are three landmarks you can use to distinguish the ovarian ligament and the round ligament? ________________________________________________________________ ________________________________________________________________ ________________________________________________________________
Write a user defined MATLAB program that performs power factor correction. The inputs to the MATLAB...
Write a user defined MATLAB program that performs power factor correction. The inputs to the MATLAB function should be voltage across the load (in Vrms, assume 0 phase), frequency Resistance of the load Inductance of the load power factor of the load target power factor The output of the function should be the size of the capacitor that one would need to place in parallel with the load to reach the target power factor. Please submit the code for the...
Instructions Write a Java code Your goal is to take N integer inputs from the user...
Instructions Write a Java code Your goal is to take N integer inputs from the user -- N's value will be given by the user as well. You can assume the user provides a valid value for N, i.e., >0. Store the input integers in an array of size N in the order they are provided. These tasks should be done in the main() method. Create a new method called checkArray() that will take the previously created array as input...
Write a program that prompts the user to input a string and outputs the string in...
Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use dynamic arrays to store the string.) my code below: /* Your code from Chapter 8, exercise 5 is below. Rewrite the following code to using dynamic arrays. */ #include <iostream> #include <cstring> #include <cctype> using namespace std; int main() { //char str[81]; //creating memory for str array of size 80 using dynamic memory allocation char *str = new char[80]; int len;...
Hi, I need a program in C, where it will prompt a user for a math...
Hi, I need a program in C, where it will prompt a user for a math quiz, either easy or medium. If the user choses difficulty easy, it will prompt the user for how many questions they would like from 1-5. If the user enters medium it will prompt the user on how many questions they would like from 1-10. After those prompts are entered questions will be displayed using rand(), the questions must be multiple choice or division, aswell...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT