In: Computer Science
This is to be done using MIPS assembly language.
Display the following menus, ask user to select one item. If 1-3 is selected, display message “item x is selected”, (x is the number of a menu item), display menus again; if 0 is selected, quit from the program.
1. Menu item 1
2. Menu item 2
3. Menu item 3
0. Quit Please select from above menu (1-3) to execute one function. Select 0 to quit
Code:
.data
menu: .asciiz "1. Menu item 1\n2. Menu item 2\n3. Menu item 3\n0. Quit \nPlease select from above menu (1-3) to execute one function. Select 0 to quit\n"
mess: .asciiz "item "
mess2: .asciiz " is selected\n"
.text
loop: li $v0,4
la $a0,menu
syscall # print the menu message
li $v0,5
syscall # accept input
move $t0,$v0 # move input to $t0
beq $t0,0,done # if 0 end loop and move to done
# print "Menu x is selected"
li $v0,4
la $a0,mess
syscall
li $v0,1
move $a0,$t0
syscall
li $v0,4
la $a0,mess2
syscall
j loop # go for next iteration of loop
done: nop
Code screenshot:
Sample output:
==============
Code has been added with screenshot. Please refer to them
For any query comment