How To Save Contents Of Register To String In Mips
You should upgrade or use an alternative browser.
- Forums
- Homework Assist
- Engineering and Comp Sci Homework Assistance
MIPS: Saving a String to register(s)?
- Thread starter pags920
- Start appointment
Homework Statement
I am currently working on a MIPS program that is supposed to catechumen letters, either lowercase or capital, to a phone number.
Two questions:
1. With the user entering a string, how do I get most in saving the string into the registers? Or would retentivity be a more than convenient choice?
2. Does anyone have any strategies or hints as to how I tin can go about in converting the string into numbers? One thought I had was to use the ASCII chart with conditional branches, but that would involve many lines of lawmaking.
Below is merely the Main subroutine.
The Endeavor at a Solution
#INITIALIZATION .data msg0: .asciiz "Please enter the phone number, expressed in messages, that you wish to convert.\north" msg1: .asciiz "You lot accept entered: \due north" msg2: .asciiz "The phone number you entered is invalid.\n" msg3: .asciiz "The phone number you entered is valid.\n" msg4: .asciiz "Your phone number, converted from letters to numbers, is \n" nl: .asciiz "\n" str: .space seven ############################################# # Primary ############################################# .text .globl main 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, iv syscall
Homework Argument
Homework Equations
The Attempt at a Solution
Answers and Replies
Caveat: I oasis't done any programming on MIPS machines, but I have washed a off-white corporeality of assembly programming using Intel x86 assembly and some on Motorola 68000.Homework Statement
I am currently working on a MIPS program that is supposed to catechumen messages, either lowercase or uppercase, to a phone number.
I would put the phone number string in memory. Your program would classify space for the input string and output string of digits in the data segment with the other variables, and your input routine would take input from the user and store it in the input string variable. Another part of your program (a dissimilar routine is my recommendation) would shop the converted cord of digits in the other variable. If you're working with local (not long-distance) U.s.a. phone numbers, seven bytes each would suffice, and that seems to be what you're doing in the code you bear witness.Two questions:1. With the user entering a string, how do I go about in saving the string into the registers? Or would retentivity exist a more convenient option?
Lets' face it - yous're writing assembly lawmaking, and then most things you lot do are going to require many lines of lawmaking.2. Does anyone take whatever strategies or hints as to how I can get about in converting the string into numbers? I thought I had was to use the ASCII nautical chart with conditional branches, merely that would involve many lines of code.
Every bit far every bit using ASCII codes for the characters, you should do this for sanity checking - to make sure that your input values are really characters, and to convert whatsoever lower-case messages to upper example. The ASCII codes for A through Z are 65 through 90 (0x41 through 0x5A in hex) and for the lower-example letters, they are 97 through 122 (0x61 thorough 0x7A). You will demand to utilise provisional branches to catechumen the characters to the respective numbers.
You'll need to make some assumptions equally to how the phone keypad is laid out. The former rotary-dial phones didn't have Q or Z, and laid out the remaining 24 letters every bit on the numbers 2 through 9. My Panasonic wireless home telephone and Nokia cell accept a different arrangement, with PQRS on the 7 key and WXYZ on the 9 key, and three letters each on the other vii keys.
The logic (shown here roughly in C) would go something similar this, bold you have already validated your input data and converted lower-instance letters to upper instance:
for (i = 0; i < 7 ; ++i) { if(char == 'A' OR char == 'B' OR char == 'C') outString[i] = 'ii'; else if (char == 'D' OR char == 'E' OR char == 'F') outString[i] = '3'; else if (char == 'G' OR char == 'H' OR char == 'I') outString[i] = '4'; . . . }
Below is only the Main subroutine.The Attempt at a Solution
#INITIALIZATION .data msg0: .asciiz "Please enter the phone number, expressed in letters, that you wish to catechumen.\northward" msg1: .asciiz "You take entered: \n" msg2: .asciiz "The phone number you lot 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 \north" nl: .asciiz "\n" str: .space 7 ############################################# # Primary ############################################# .text .globl main primary: la $a0, msg0 li $v0, iv syscall la $a0, str li $a1, viii li $v0, eight syscall la $a0, nl li $v0, 4 syscall la $a0, msg1 li $v0, 4 syscall la $a0, str li $v0, iv syscall
Related Threads on MIPS: Saving a String to register(south)?
- Concluding Post
- Final Post
- Last Post
- Last Post
- Last Post
- Last Post
- Final Mail
- Final Post
- Last Post
- Last Mail service
- Forums
- Homework Assistance
- Applied science and Comp Sci Homework Aid
How To Save Contents Of Register To String In Mips,
Source: https://www.physicsforums.com/threads/mips-saving-a-string-to-register-s.435945/
Posted by: mckenzienotilen.blogspot.com
0 Response to "How To Save Contents Of Register To String In Mips"
Post a Comment