Starting from:
$35

$29

Program #1 Solution

Objectives

    1. Introduction to MASM assembly language

    2. Defining variables (integer and string)

    3. Using library procedures for I/O

    4. Integer arithmetic

Description

Write a MASM program to perform the tasks listed below. Test your program to ensure that it functions correctly.

1. Display your name and program title on the output screen.

2. Display instructions for the user.

3. Prompt the user to enter two numbers.


4. Calculate the sum, difference, product, (integer) quotient and remainder of the numbers.

5. Display a terminating message.

Requirements

    1. The main procedure must be divided into sections:

  introduction

  get the data

  calculate the required values

  display the results

  say goodbye

    2. The results of calculations must be stored in named variables before being displayed.
    3. The program must be fully documented. This includes a complete header block for identification, description, etc., and a comment outline to explain each section of code.
    4. Submit your text code file (.asm) to Canvas by the due date.

Notes

    1. A program shell (template) is available on the course website. See the Week 1 Basics page in Modules.

    2. You are not required to handle negative input or negative results.

    3. You have a limited number of late days. Try not to use these on the first program.

    4. To create, assemble, run, debug, and modify your program, follow the setup instructions available within Canvas on the Syllabus –> Tools page.
    5. Find the assembly language instruction syntax in the textbook.

    6. Documentation for the Irvine library procedures is provided in the textbook.

Example Program Operation


Elementary Arithmetic by Wile E. Coyote

Enter 2 numbers, and I'll show you the sum, difference, product, quotient, and remainder.

First number: 37
Second number: 5

37+5=42

37-5=32

37 x 5 = 185

37 / 5 = 7 remainder 2
Impressed? Bye!


Extra Credit Options (original definition must be fulfilled)

    1. (1 pt) Validate the second number to be less than the first.

    2. (1 pt) Display the square of each number. Recall that the square of a number is obtained by mutiplying a number by itself. For example:


Square of 37 = 1369

Square of 5 = 25

To ensure you receive credit for any extra credit options you did, you must add one print statement to your program output PER EXTRA CREDIT which describes the extra credit you chose to work on. You will not receive extra credit points unless you do this. The statement must be formatted as follows...

--Program Intro--

**EC: DESCRIPTION

--Program prompts, etc—

For example, for extra credit option #1:


Elementary Arithmetic by Wile E. Coyote

**EC: Program verifies second number less than first.

Enter 2 numbers, and I'll show you the sum, difference, product, quotient, and remainder.

First number: 7

Second number: 9

The second number must be less than the first!

Impressed? Bye!



Program 1 Rubric

Criteria

Ratings
Pts





Preliminaries - Files Correctly Submitted
1 pts

0 pts

Submitted file is correct assignment and is an individual .asm file.





Full Marks

No Marks
1 pts











Preliminaries - Program assembles, links
2 pts
0 pts
Submitted program assembles and links without need for clarifying



Full Marks
No Marks
work for TA and/or messages to the student. This assumes the


program is actually an attempt at the assignment. Non-attempts


which compile/link earn no points.

2 pts







Documentation - Identification Block - Header
2 pts
0 pts
Name, OSU Email, Course number, Program number, Date, etc as



Full Marks
No Marks
per
syllabus are included in Identification Block

2 pts













Documentation - Identification Block - Program Description
2 pts
1 pts
0 pts

Description of functionality and purpose of program is included in





Full
Lacking detail
No

identification block.
Marks
Description is present but is lacking in detail with
Marks
2 pts


regard to functionality.







Criteria


Ratings
Pts





Verification - Program Executes
5 pts
2 pts
0 pts

Program executes and makes some attempt at the assigned





Full
Failed attempt
Wrong Program

functionality.
Marks
Program is an
Program executes but is either the



attempt at the correct
incorrect program or some quickly
5 pts


assignment but
mashed together nonsense, submitted








simply does not run.
only to 'get a few points'







Completeness - Displays programmer name
1 pts
0 pts
Program prints out the programmer's name.



Full Marks
No Marks
1 pts




Completeness - Displays Introduction
2 pts
0 pts
Program displays the program introduction.



Full Marks
No Marks
2 pts










Completeness - Prompts user to input data
1 pts
0 pts
Program outputs a data request to user e.g. "Enter a number" twice.



Full Marks
No Marks
1 pts



Completeness - Gets data from user
2 pts
0 pts
Utilizes ReadDec or ReadInt, gets user-input data, and saves data



Full Marks
No Marks
to some memory variable (non-register).

2 pts






Criteria


Ratings
Completeness - Displays Results

2 pts

0 pts





Program displays results in the form of






Full Marks

No Marks
(X+Y=M|




X-Y=N|




X*Y=O|




X / Y = Q remainder R)










Correctness - Calculations are correct
5 pts
0 pts
Calculations are all correct. Lose 1 point per incorrect calculation



Full Marks
No Marks
(Sum | Difference | Product | Quotient | Remainder)






Correctness - Original User Data Unchanged
2 pts
0 pts
Original variables holding user-entered data (num1, num2) remain



Full Marks
No Marks
unchanged by all calculations and still hold original user-entered


data
at end of execution.














Pts






2 pts











5 pts











2 pts



Criteria



Ratings

Pts











Requirements - Modularized Code Blocks
5 pts

3 pts
3 pts
0 pts


Main procedure is separated into functional sections, each of which








Blocks

Blocks without
Headers without Blocks
No


is described by comments.
with

Headers
Program is not visibly
Marks





Headers

Program is
separated into logical blocks








separated into
with whitespace, but limited

5 pts






logical blocks but
headers do indicate some


















those blocks are
organizational effort.








poorly commented















Requirements - Results stored in named variables
5 pts


0 pts



Results of calculations are stored in memory in discrete variables.








Full Marks


No Marks



Lose 1 point per missing variable usage (Sum | Difference | Product








| Quotient | Remainder)






5 pts


































Coding
Style - In-line Comments
5 pts


0 pts



In-line comments and block headers describe functionality of








Full Marks


No Marks











program flow. Should mirror the style guide image.






5 pts

























Criteria


Ratings

Pts











Coding Style - Appropriately Named Identifiers
3 pts

1 pts

0 pts


Identifiers named so that a person reading the code can intuit the








Full

Partial

No


purpose of a variable, constant, or label just by reading its name.
Marks

Some identifiers are named well, with others having no
Marks
3 pts





relevance to their functionality.























Coding Style - Readability
5 pts

3 pts

0 pts


Program uses readable white-space, indentation, and spacing as








Full

Marginally Readable

No


per the Indentation Style Guide. Logical sections are separated by
Marks

Program is marginally readable but lacks proper
Marks
5 pts

white space.


alignment and white space.























Late Penalty
0 pts



0 pts



Remove points here for late assignments. (Enter negative point









Full Marks

No Marks

0 pts

value)



























No
prohibited macros (see lecture 6) REJECT ASSIGNMENT
0 pts



0 pts













None of the assignments are allowed to use .IF, .IFELSE, or related









Full Marks

No Marks



macros. Only actual assembly code.






0 pts































Criteria

Ratings

Pts






Extra Credit (1pt) - validate that num2 is less than num1
0 pts

0 pts


Assuming that num1 and num2 are non-zero positive integers, the






Full Marks

No Marks


code must generate an error if num2 is greater than or equal to




0 pts
num1.











Extra Credit (1pt) - display mathematical square of the user's
0 pts

0 pts


numbers






Full Marks

No Marks








The code displays the square value of the numbers that the user





entered (see assignment for explanation).




0 pts
















Total Points: 50






More products