Question: Modify the read string procedure in the code below to read in a variable length string using Interrupt I / O not polling. Check its
Modify the "read string" procedure in the code below to read in a variable length string using Interrupt IO not polling. Check its operation by reading in a string and examining it in the input buffer. You do not need to write the string out to the display but if you want to undertake that addition to the assignment using interrupt handling there will be a significant amount of extra credit. A few hints....... You will need a buffer to hold the string that is input. Normally this would be allocated by the calling program and passed as an argument to the read string procedure. The read string procedure introductory code would save the buffer address in a kernel data structure in kdata along with the counter of the next character to be entered. How does main know when the data input is complete? The operating system would provide a waitpost mechanism to communicate the fact that the input is complete. This waitpost mechanism can be simulated by passing the read string routine the address of a control word in memory to signal the read complete. The word would contain while the input is being handled. The word would be set to when the read string is complete. The read string routine would save the address of this control word along with the buffer address and count in the read string data structure. When the NL is entered the read string would place a NULL in the buffer, set the control word to and run the epilog code to restore registers. The main routine on MARS would test the control word for in the wait loop since we do not have a real wait function in MARS. text globl readString readString: li $t readloop: li $txFFFF # Address of the keyboard pollkeyboard: lw $t$t # Load the register andi $t $t # Check if input is ready beq $t $zero, pollkeyboard li $txFFFF # Address of the keyboard lw $t$t # Loads the input character li $txA beq $t $t endread sb $t$a # Store the character at string addi $a $a # Move to the next position in the string j readloop # Continues to read endread: li $tx # Null then terminates the string sb $t$a # Store null character at the end jr $ra # Return from the function
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
