In: Computer Science
Write a mips assembly language program that asks the user to enter an alphabetic character (either lower or upper case)and change the case of the character from lower to upper and from upper to lower and display it.
MIPS
The MIPS, or Microprocessor without Interlocked Pipeline Stages, assembly code was developed by MIPS Computer Systems. There are six major implementations of the code. The two current implementations are MIPS32 and MIPS64, which support 32-bit and 64-bit operating instructions, respectively. MIPS uses a two-character alphanumeric codes to represent different letters and characters such as operands.
Steps for program:
Step 1 :
Open the MIPS code
Step 2 :
Locate the code containing lowercase and vice versa.The numbers are used to represent letters.For example, letters "a" to "i" are represented by numbers from 61 to 69.The letters "j" through "o" are represented by 6A to 6F. The letters "p" through "y" are represented by 70 to 79. The letter z is represented by 7A.
Program :
.data
lower: .ascii "aaaa"
upper: .ascii "xxxx"
.text
loop:
lb $t1, lower($t0)
beq $t1, 0, exit
sub $t1, $t1, 32
sb $t1, lower($t0)
add $t0, $t0, 1
.j loop
lb $t1, upper($t0)
beq $t2, 0, exit
sub $t2, $t2, 32
sb $t2, upper($t0)
add $t0, $t0, 2
.j loop
exit :
lw $t1, lower
sw $t2, upper
li $v0, 10
syscal
Note : Programming in assembly language is easy for memory swapping and memory related purposes.