CMSI 284 Computer System Organization/Systems Programming, Spring 2019
For these assembly language programs, we go back to how we started, with system calls—those built-in operating system-level services invoked by
In addition to Dr. Toal’s assembly language pages (all linked from the course website), you’ll want to scan this list of 64-bit Linux system calls (or this one) in order to pick the one which you’ll invoke for this assignment. When you see a system call that you find interesting, just do a web search for something like “Linux 64-bit system call
system_call_name” to find more detailed information about that system call.
You have seen examples for
exit—there’s lots more you can do!
For Submission: System Call Me Maybe
Examine the aforementioned lists of 64-bit Linux system calls and pick a system call that you find interesting. Implement an assembly language program that invokes that system call using any applicable command-line arguments and displays appropriate message or output. This is pretty much how Linux operating system commands are implemented!
Some implementation notes/tips:
- Nearly all system calls require some set of parameters so you will want to link with
gccin order to have easy access to
argvas usual, as well as library functions like
printf. Be cognizant of the system call parameters’ data types (
- Keep things simple. Some system calls return complex structures—great information and definitely interesting, but likely over your head.
- Choose something whose result is easily demonstrable, such as easily verifiable information or concrete, tangible results (like those mentioned in the next item).
- System calls that manipulate files (such as
unlink) don’t necessarily have direct output but instead affect the specified file or folder. These can be “no news is good news” programs, but do display a message if an error is detected. You can examine the affected file(s) or folder(s) to see if your system call worked.
- Remember that you are supposed to invoke the system call directly, not through C. If your code doesn’t have the
syscallinstruction, then you’re doing it wrong.
- One system call is off-the-table:
chdir. Calling this in a separate program won’t work as you expect. You’ll see why when you learn about process management in Operating Systems.
exitare also off the table for (I hope) obvious reasons. However, you may use these system calls in supporting roles.
- Yes there is a
rebootsystem call. It does what it says, so save your work if you want to try invoking it.
- If you decide to use a system call that delivers its results to a block of memory that you supply, it will be easier to just use
.datasection to pre-allocate space rather than to dynamically allocate memory via
How to Turn it In
Commit your source code (and just the source code)—i.e., the .asm file—to this repository. Filenames will vary because they will depend on the system call that you choose.
Specific Point Allocations
This assignment is scored according to outcomes 2c, 2d, 3a, 3b, 3c, and 4a to 4f in the syllabus. For this particular assignment, graded categories are as follows:
|• Assembles, links, and runs without unexpected errors||20 points||3a, 4a, 4d|
|• Correct system call invocation (
||10 points||3c, 4a, 4d|
|• Correct program output or result||40 points||2c, 2d, 3b, 3c, 4a, 4d|
|• Correct handling of invalid user input or erroneous results||30 points||2c, 2d, 3b, 3c, 4a, 4d|
|Hard-to-maintain or error-prone code||deduction only||4b|
|Hard-to-read code||deduction only||4c|
|Version control||deduction only||4e|
Note that inability to assemble, link, and run to begin with will negatively affect the correctness of program output and proper handling of invalid user input.