.globl main
.data
input: .word 0x1
str0: .asciiz “In Choice 0 :”
str1: .asciiz “In Choice 1 :”
str2: .asciiz “In Choice 2 :”
exitcmd: .word choice0 choice1 choice2
.text
main:
lw t0, input
li t1,3
bgt t3,t0,exit
slli t0,t0,2
la t1,exitcmd
add t1,t1,t0
lw t1, 0 (t1)
jalr t1
choice0:
la a1, str0
addi a0, x0, 4 # prepare for print string syscall
ecall
addi a0, x0, 1
addi a1, t0, 0
ecall
jal exit
choice1:
la a1, str1
addi a0, x0, 4 # prepare for print string syscall
ecall
addi a0, x0, 1
addi a1, x0, 1
ecall
jal exit
choice2:
la a1, str2
addi a0, x0, 4 # prepare for print string syscall
ecall
addi a0, x0, 1
addi a1, x0, 2
ecall
jal exit
exit:
addi a0, x0, 10
ecall # terminate ecall