Skip to main content
Engineering LibreTexts

13.9: Exercises

  • Page ID
    58405
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Below are some quiz questions and suggested projects based on this chapter.

    Quiz Questions

    Below are some quiz questions based on this chapter.

    1) When using a system service, where is the call code placed?

    2) Where is the code located when the syscall instruction is executed?

    3) What is the call code and required arguments for a system service call to perform console output?

    4) Why was only one character read for interactive keyboard input?

    5) What is returned for a successful file open system service call?

    6) What is returned for an unsuccessful file open system service call?

    7) If a system service call requires six (6) arguments, where specifically should they be passed?

    Suggested Projects

    Below are some suggested projects based on this chapter.

    1) Implement the printString() example void function and a simple main to test of a series of strings. Use the debugger to execute the program and display the final results. Execute the program without the debugger and verify the appropriate output is displayed to the console.

    2) Convert the example program to read input from keyboard into a readString() function. The function should accept arguments for the string address and maximum string length (in that order). The maximum length should include space for the NULL (an extra byte), which means the function must not allow more than the maximum minus one characters to be stored in the string. If additional characters are entered by the user, they should be cleared from the input stream, but not stored. The function should not include the newline in the returned string. The function should return the number of characters in the string not including the NULL. The printString() function from the previous problem should be used unchanged. When done, create an appropriate main to test the function. Use the debugger as necessary to debug the program. When working correctly, execute the program from the command line which will display the final results to the console.

    3) Based on the file write example, create a value returning fileWrite() function to write a password to a file. The function should accept arguments for the address of the file name and the address of the NULL terminated password string. The file should be created, opened, the password string written to the file, and the file closed. The function should return SUCCESS if the operations worked correctly or NOSUCCESS if there is a problem. Problems might include not being able to create the file or not being able to write to the file. Create an appropriate main to test the function. Use the debugger as necessary to debug the program. When working correctly, execute the program from the command line which will display the final results to the console.

    4) Based on the file read example, create a value returning fileRead() function to read a password from a file. The function should accept arguments for the address of file name, the address of where to store the password string, the maximum length of the password string, and the address of where to store the password length. The function should open the file, read a string representing a password, close the file, and return the number of characters in the password. The maximum length should include space for the NULL, which means the function read must not store more than the maximum minus one characters in the string. The function should return SUCCESS if the operations worked correctly or NOSUCCESS if there is a problem. Problems might include the file not existing or other read errors. Create an appropriate main to test the function. Use the debugger as necessary to debug the program. When working correctly, execute the program from the command line which will display the final results to the console.


    13.9: Exercises is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?