In: Computer Science
(Make sure in Mips!!!) Use the correct “syscall” to create MIPS programs for the following.
!!! please use comments and ALWAYS use the correct syscall program code to end the program. !!!
1) Write a program in MIPS which asks the user to enter their favorite type of pie. The program should then print out "So you like _____ pie", where the blank line is replaced by the pie type entered.
ALSO: What annoying feature of syscall service 4 makes it impossible at this point to make the output appear on a single line???
(Make sure to comment and show screenshot if possible.)
Greetings!!
Code:
.data
prompt: .asciiz "Please enter your favourite type of pie\n"
mes1: .asciiz "So you like "
mes2: .asciiz "pie"
pie: .space 20
.text
#MAIN STARTS HERE
main:
#DISPLAY THE PROMPT MESSAGE
la $a0,prompt #load the address of the prompt message
li $v0,4 #parameter for display string
syscall #display
#READ STRING FROM THE USER
la $a0,pie #load the address of string
li $a1,20 #number of characters to be read
li $v0,8 #parameter for reading string
syscall #read
#DISPLAY THE MESSAGE SO YOU LIKE
la $a0,mes1 #load the address of the prompt message
li $v0,4 #parameter for display string
syscall #display
#DISPLAY THE STRING READ FROM THE USER
la $a0,pie #load the address of the prompt message
li $v0,4 #parameter for display string
syscall #display
#DISPLAY THE MESSAGE PIE
la $a0,mes2 #load the address of the prompt message
li $v0,4 #parameter for display string
syscall #display
#END OF THE PROGRAM
li $v0,10 #parameter for display string
syscall #display
Output screenshot:
Hope this helps