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

Assignment 5 Write a MIPS program that asks users to setup a password (length be

ID: 2268395 • Letter: A

Question

Assignment 5 Write a MIPS program that asks users to setup a password (length between 8 and 12; with only upper and lower case letters). Prompt the user to enter the password string and check if it meets the requirements. If the password string does not meet the requirements, print out an error message and prompt the user for a second try. In the case the user does not enter the proper password string again, display an error message and terminate the program. Otherwise, prompt the user for re-entering the password string. If the entered string is correct, display an appropriate message and terminate the program. If not, give the user two more chances before terminating the program with an error message. Example of program output on console: Set a password: Lab Failed. Please enter a password with the size of 8 to 12! Set a password: Lablablab Re-enter the password: Lab Incorrect, you have 2 more chance! Please re-enter the password: Lablablab Password is setup.

Explanation / Answer

CODE;-

#Read the String and save it in s0

nop

nop

li a0,0 # firs argument, for stdin is 0 ISTR, see "man 2 read"

la a1,(var1) # second argument load adress of var1 into a1

li a2,12 # third argument is count of byts

li v0,__NR_read

syscall

move t0, v0

#Print the message

li a0,1 # first argument fd 1

la a1,output # second argument memory location of hello string

li a2,256 # lenght of string to print

li v0,__NR_write # syscall write,they are defined in unistd.h

syscall

#Output the string

nop

nop

quit: # label quit

li v0,__NR_exit # load system call for exit in v0

syscall

nop

END(main)

.data