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!!!
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 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...
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? ________________________________________________________________ ________________________________________________________________ ________________________________________________________________
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...
Financing government services through user fees generally leads to a debate/comparison of fees v. taxes. Please...
Financing government services through user fees generally leads to a debate/comparison of fees v. taxes. Please describe and define a fee and a tax, identifying the significant differences between the two. What are the three factors that determine what a fee should be? PLEASE provide examples to support your analysis.
When counseling employees what would be the correct and proper way to correct the following statements:...
When counseling employees what would be the correct and proper way to correct the following statements: a) Your laziness is becoming a problem. b) Stop shouting. You have no right to be angry; just look at your performance. c) There would be no problems if you took your work more seriously. Explin your answers. Question 2 options:
what is correct order of blood flow through the cardiovascular system
what is correct order of blood flow through the cardiovascular system
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 6.) Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will...