Skip to main content
Engineering LibreTexts

14.4: Exercises

  • Page ID
    19949
  • \( \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) What is the statement to declare the functions, func1() and func2(), as external assuming no arguments are needed for either function?

    2) What is the statement to declare the functions, func1() and func2(), as external if two integer arguments are used for each function?

    3) What will happen if an external function is called but is not declared as external?

    4) If an externally declared function is called but the programmer did not actually write the function, when would the error be flagged, assemble-time, link-time, or run-time?

    5) If an externally declared function is called but the programmer did not actually write the function, what might the error be?

    6) If the “-g” option is omitted from the assemble and link commands, would the program be able to execute?

    Suggested Projects

    Below are some suggested projects based on this chapter.

    1) Implement the as sembly language example program to find the sum and average for a list of signed integers. Ensure that the main and function are in different source files. Use the debugger to execute the program and display the final results.

    2) Based on the example function stats(), split it into two value returning functions, lstSum() and lstAverage(). As noted in Chapter 12, Functions, value returning functions return their result in the A register. Since these are double-words, the result will be returned in eax. Ensure that the main and both functions are in two different source files. The two functions can be in the same source file. Use the debugger to execute the program and display the final results.

    3) Extend the previous exercise to display the sum and average to the console. The printString() example function (from multiple previous examples) should be placed in a third source file (which can be used on other exercises). This project will require a function to convert an integer to ASCII (as outlined in Chapter 10). Use the debugger as needed to debug the program. When working, execute the program without the debugger and verify that the correct results are displayed to the console.

    4) Implement one of the C/C++ example main programs (either one). Additionally, implement the assembly language stats() function example. Develop a simple bash script to perform the compile, assemble, and link. The link should be performed with the applicable C/C++ compiler. Use the debugger as needed to debug the program. When working, execute the program without the debugger and verify that the correct results are displayed to the console.


    This page titled 14.4: Exercises is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Ed Jorgensen.

    • Was this article helpful?