- #1
pags920
- 21
- 0
Homework Statement
I am currently working on a MIPS program that is supposed to convert letters, either lowercase or uppercase, 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 convenient choice?
2. Does anyone have any strategies or hints as to how I 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 code.
Below is only the Main subroutine.
The Attempt at a Solution
Code:
#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 phone number you entered is valid.\n"
msg4: .asciiz "Your phone number, converted from letters to numbers, is \n"
nl: .asciiz "\n"
str: .space 7
#############################################
# Main
#############################################
.text
.globl main
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