In MIPS, a list of five strings are pre-stored in the \"Data Segment\". Please \
ID: 3597735 • Letter: I
Question
In MIPS, a list of five strings are pre-stored in the "Data Segment".
Please "print out" the pre-stored strings in alphabetical order (regarding the first character) using MIPS.
I have tried multiple times to get this to work and cannot get anything to work. Help would be much appreciated.
This is the code I have with the strings required, I just cannot get it to print alphabetically:
.data
String1:
.asciiz "Applebee"
String2:
.asciiz "subway"
String3:
.asciiz "Fire House"
String4:
.asciiz "Red Lobster"
String5:
.asciiz "Moe's"
.text
.globl main
main:
# Your code starts here
Explanation / Answer
.text #directive identifying the start of instructions
.globl __start
__start:
la $a0, prompt # address of prompt
li $v0, 4 # service code for string
syscall
li $v0, 5 # service code
syscall
sw $v0, Num1 # stores the value
li $v0, 5 # service code
syscall
sw $v0, Num2 # store the given value
$a0 := Num1 + Num2
lw $t0, Num1
add $a0, $t0, $v0
li $v0, 1 # print integer
syscall
la $a0, final
li $v0, 4
syscall
li $v0, 10 # exit
syscall
# Data segment
.data
Num1: .word 0
Num2: .word 0
prompt: .ascii "Givre 2 integers, end each with the "
.asciiz "Enter key: "
final: .asciiz " is the sum. "
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.