Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need a writing program in Mars Mips The second program will demonstrate how to w

ID: 669321 • Letter: N

Question

Need a writing program in Mars Mips

The second program will demonstrate how to write selection statements in MIPS. Your program should load from memory the contents of character variable LETTER. If LETTER is an alphabetical character, your program should change its case (i.e., replace an UPPER-CASE letter with the corresponding lower-case value, or vice versa) and set Boolean variable VALID to true; otherwise, your program should replace the value of LETTER with a ‘?’ and set VALID to false. Use 0 and 1 to represent false and true, respectively.

Explanation / Answer

.text

main:

la $t0,LETTER

lw $t1,0($t0)

addi $t2, $zero, 65        # set t2 = 'A'
blt   $t1, $t2, NonAlpha # if (LETTER < 'A') goto NonAlpha

addi $t2, $zero, 90        # set t2 = 'Z'
ble   $t1, $t2, DoLowerAlpha     # if (LETTER <= 'Z') goto DoLowerAlpha   

addi $t2, $zero, 97        # set t2 = 'a'
blt   $t1, $t2, NonAlpha # if (LETTER < 'a') goto NonAlpha

addi $t2, $zero, 122       # set t2 = 'z'
blt   $t1, $t2, DoUpperAlpha # if (LETTER<'z') goto DoUpperAlpha

addi $t2, $zero, 122       # set t2 = 'z'
blt   $t2, $t1, NonAlpha # if ('z' < LETTER) goto NonAlpha

NonAlpha:
la $t5, q
lw $t2, 0($t5)
sw $t2, 0($t0)
la $t3, VALID
addi $t4,$zero,0
sw $t4,0($t3)

DoLowerAlpha:
addi $t2 , $t2, 32
sw $t2, 0($t0)
la $t3, VALID
addi $t4,$zero,1
sw $t4,0($t3)


DoUpperAlpha :
subi $t2 , $t2, 32
sw $t2, 0($t0)

la $t3, VALID
addi $t4,$zero,1
sw $t4,0($t3)
.data

VALID : .word 0
q: .asciiz "?"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote