Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
94 lines (62 sloc) 4.52 KB

CMSI 284 Computer System Organization/Systems Programming, Spring 2019

Assignment 0416

We warm up to assembly language with some programs that may feel…familiar.

Background Reading

Pretty much all of the information you need can be found in Dr. Toal’s assembly language pages (all linked from the course website). Assembly language beginner and tutorial pages are harder to find on the web, but there are bound to be some out there.

For Submission: Déjàssembly Vu

Write the requested x86 assembly language programs for Linux. The programs have been chosen for both simplicity and familiarity, because, well, assembly language.

Make Quarter Change

Write an x86 assembly language program for Linux, make-quarter-change.asm, that takes a command line argument for a total number of cents and computes the number of quarters that can be changed for that amount.

Sample program invocation and output:

$ ./make-quarter-change 142
5 quarters make partial change for 142 cents.

Don’t worry about singular vs. plural cents or quarters. It’s assembly language; we understand. Also, don’t worry about a negative amount. Yup, assembly language again.

If the wrong number of command line arguments is supplied, the program should respond as follows:

$ ./make-quarter-change
This program requires exactly one integer command line argument.

Or:

$ ./make-quarter-change 78 12 33
This program requires exactly one integer command line argument.

Because atoi just returns 0 on bad input values, don’t worry about detecting those:

$ ./make-quarter-change bazinga
0 quarters make partial change for 0 cents.

As with previous assignments, the grading of this assignment will be semi-automated, so it is very important that you adhere strictly to the specified output messages and format.

Is Probably Leap Year?

Write an x86 assembly language program for Linux, is-probably-leap-year.asm, that takes a command line argument for an integer year and computes whether that year is divisible by four.

Sample program invocation and output:

$ ./is-probably-leap-year 1942
1942 is probably not a leap year.

$ ./is-probably-leap-year 1900
1900 is probably a leap year.

(no, 1900 is not a leap year—that’s why we just say “probably”)

Don’t worry about negative years. Say it with me: assembly language.

If the wrong number of command line arguments is supplied, the program should respond as follows:

$ ./is-probably-leap-year
This program requires exactly one command line argument specifying a year.

Or:

$ ./is-probably-leap-year 1985 2001 2019
This program requires exactly one command line argument specifying a year.

Because atoi just returns 0 on bad input values, don’t worry about detecting those:

$ ./is-probably-leap-year bazinga
0 is probably a leap year.

As with previous assignments, the grading of this assignment will be semi-automated, so it is very important that you adhere strictly to the specified output messages and format.

How to Turn it In

Commit your source code (and just the source code)—make-quarter-change.asm and is-probably-leap-year.asm—to this repository.

Specific Point Allocations

This assignment is scored according to outcomes 2c, 2d, 3a, 3b, and 4a to 4f in the syllabus. For this particular assignment, graded categories are as follows:

Category Points Outcomes
make-quarter-change.asm 50 points total
• Assembles, links, and runs without unexpected errors 10 points 3a, 4a, 4d
• Correct program output 25 points 2c, 2d, 3b, 4a, 4d
• Correct handling of invalid user input 15 points 2c, 2d, 3b, 4a, 4d
is-probably-leap-year.asm 50 points total
• Assembles, links, and runs without unexpected errors 10 points 3a, 4a, 4d
• Correct program output 25 points 2c, 2d, 3b, 4a, 4d
• Correct handling of invalid user input 15 points 2c, 2d, 3b, 4a, 4d
Hard-to-maintain or error-prone code deduction only 4b
Hard-to-read code deduction only 4c
Version control deduction only 4e
Punctuality deduction only 4f
Total 100

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.

You can’t perform that action at this time.