How To Load A Specific Array Value Into A Register In Mips
You should upgrade or employ an alternative browser.
- Forums
- Homework Aid
- Applied science and Comp Sci Homework Help
MIPS: Saving a String to register(s)?
- Thread starter pags920
- Showtime engagement
Homework Statement
I am currently working on a MIPS program that is supposed to catechumen messages, either lowercase or capital, to a phone number.
Two questions:
1. With the user entering a string, how do I go about in saving the string into the registers? Or would memory be a more user-friendly choice?
2. Does anyone have whatsoever strategies or hints as to how I can go about in converting the cord into numbers? I thought I had was to apply the ASCII nautical chart with conditional branches, simply that would involve many lines of code.
Beneath is only the Master subroutine.
The Try at a Solution
#INITIALIZATION .data msg0: .asciiz "Please enter the phone number, expressed in letters, that you wish to convert.\n" msg1: .asciiz "You have entered: \n" msg2: .asciiz "The phone number you entered is invalid.\n" msg3: .asciiz "The telephone number you entered is valid.\n" msg4: .asciiz "Your phone number, converted from letters to numbers, is \n" nl: .asciiz "\n" str: .infinite 7 ############################################# # Main ############################################# .text .globl chief main: la $a0, msg0 li $v0, 4 syscall la $a0, str li $a1, 8 li $v0, 8 syscall la $a0, nl li $v0, 4 syscall la $a0, msg1 li $v0, 4 syscall la $a0, str li $v0, 4 syscall Homework Statement
Homework Equations
The Try at a Solution
Answers and Replies
Caveat: I haven't done any programming on MIPS machines, but I have done a fair amount of assembly programming using Intel x86 assembly and some on Motorola 68000.Homework Argument
I am currently working on a MIPS program that is supposed to convert letters, either lowercase or upper-case letter, to a phone number.
I would put the phone number cord in retention. Your programme would allocate space for the input string and output string of digits in the data segment with the other variables, and your input routine would accept input from the user and store information technology in the input string variable. Another part of your program (a different routine is my recommendation) would store the converted string of digits in the other variable. If you're working with local (not long-distance) U.s. phone numbers, vii bytes each would suffice, and that seems to be what you're doing in the code yous show.Ii questions:1. With the user inbound a string, how exercise I go about in saving the string into the registers? Or would retention be a more convenient choice?
Lets' face it - you're writing associates code, so well-nigh things you practice are going to crave many lines of code.ii. Does anyone have any strategies or hints equally to how I can go almost in converting the cord into numbers? One thought I had was to use the ASCII chart with provisional branches, but that would involve many lines of code.
Equally far equally using ASCII codes for the characters, you should practise this for sanity checking - to make sure that your input values are actually characters, and to convert whatsoever lower-case letters to upper case. The ASCII codes for A through Z are 65 through 90 (0x41 through 0x5A in hex) and for the lower-case messages, they are 97 through 122 (0x61 thorough 0x7A). You will need to employ conditional branches to catechumen the characters to the corresponding numbers.
You'll demand to make some assumptions as to how the telephone keypad is laid out. The old rotary-dial phones didn't have Q or Z, and laid out the remaining 24 messages equally on the numbers 2 through ix. My Panasonic wireless home phone and Nokia cell have a different system, with PQRS on the 7 central and WXYZ on the nine key, and three letters each on the other seven keys.
The logic (shown here roughly in C) would go something similar this, assuming you accept already validated your input information and converted lower-case letters to upper instance:
for (i = 0; i < 7 ; ++i) { if(char == 'A' OR char == 'B' OR char == 'C') outString[i] = '2'; else if (char == 'D' OR char == 'E' OR char == 'F') outString[i] = 'three'; else if (char == 'G' OR char == 'H' OR char == 'I') outString[i] = '4'; . . . } Below is merely the Main subroutine.The Attempt at a Solution
#INITIALIZATION .data msg0: .asciiz "Please enter the telephone number, expressed in letters, that you wish to catechumen.\due north" msg1: .asciiz "You have entered: \northward" msg2: .asciiz "The telephone number you entered is invalid.\northward" msg3: .asciiz "The phone number you entered is valid.\due north" msg4: .asciiz "Your phone number, converted from letters to numbers, is \n" nl: .asciiz "\n" str: .infinite seven ############################################# # Main ############################################# .text .globl chief main: la $a0, msg0 li $v0, 4 syscall la $a0, str li $a1, 8 li $v0, eight syscall la $a0, nl li $v0, 4 syscall la $a0, msg1 li $v0, 4 syscall la $a0, str li $v0, 4 syscall
Related Threads on MIPS: Saving a String to register(s)?
- Last Postal service
- Last Mail service
- Last Post
- Concluding Post
- Final Mail service
- Terminal Postal service
- Final Postal service
- Last Postal service
- Terminal Mail service
- Last Post
- Forums
- Homework Aid
- Engineering science and Comp Sci Homework Help
How To Load A Specific Array Value Into A Register In Mips,
Source: https://www.physicsforums.com/threads/mips-saving-a-string-to-register-s.435945/
Posted by: teddermong1995.blogspot.com

0 Response to "How To Load A Specific Array Value Into A Register In Mips"
Post a Comment