Introduction This program, the portfolio project for the class, is the final step up in difficulty. Once again the Rubric (see below) now has a number of point deductions for not meeting requirements....


Introduction


This program, the portfolio project for the class, is the final step up in difficulty. Once again the Rubric (see below) now has a number of point deductions for not meeting requirements. It it not uncommon for a student to generate a program that meets theProgram Descriptionbut violates severalProgram Requirements, causing asignificantloss in points. Please carefully review the Rubric to avoid this circumstance.


The purpose of this assignment is to reinforce concepts related to string primitive instructions and macros (CLO 3, 4, 5).



  1. Designing, implementing, and callinglow-level I/O procedures

  2. Implementing and usingmacros


What you must do



Program Description


Write and test a MASM program to perform the following tasks (check the Requirements section for specifics on program modularization):



  • Implement and test twomacrosfor string processing. These macros may use Irvine’s
    ReadString
    to get input from the user, and
    WriteString
    procedures to display output.



    • mGetString
      : Display a prompt(input parameter, by reference), then get the user’s keyboard input into a memory location(output parameter, by reference). You may also need to provide acount(input parameter, by value)for the length of input string you can accommodate and a provide a number of bytes read (output parameter, by reference)by the macro.



    • mDisplayString
      : Print the string which is stored in a specified memory location(input parameter, by reference).



  • Implement and test twoproceduresfor signed integers which use string primitive instructions



    • ReadVal
      :

      1. Invoke the
        mGetString
        macro (see parameter requirements above) to get user inputin the form of a string of digits.

      2. Convert (using string primitives) the string of ascii digits to its numeric value representation (SDWORD), validating the user’s input is a valid number (no letters, symbols, etc).

      3. Store this one value in a memory variable(output parameter, by reference).





    • WriteVal
      :

      1. Convert a numeric SDWORD value(input parameter, by value)to a string of ascii digits

      2. Invoke the
        mDisplayString
        macro to print the ascii representation of the SDWORD value to the output.





  • Write a test program (in
    main
    ) which uses the
    ReadVal
    and
    WriteVal
    procedures above to:

    1. Get 10 valid integers from the user. Your
      ReadVal
      will be called within the loop in
      main
      . Do not put your counted loop within
      ReadVal
      .

    2. Stores these numeric values in an array.

    3. Display the integers, their sum, and their average.



  • Your
    ReadVal
    will be called within the loop in
    main
    . Do not put your counted loop within
    ReadVal
    .



Program Requirements



  1. User’s numeric inputmustbe validated the hard way:

    1. Read the user's input as a string andconvert the string to numeric form.

    2. If the user enters non-digits other than something which will indicate sign (e.g. ‘+’ or ‘-‘), or the number is too large for 32-bit registers, an error message should be displayed and the number should be discarded.

    3. If the user enters nothing (empty input), display an error and re-prompt.





  2. ReadInt
    ,
    ReadDec
    ,
    WriteInt
    , and
    WriteDec
    arenot allowedin this program.

  3. Conversion routinesmustappropriately use the
    LODSB
    and/or
    STOSB
    operators for dealing with strings.

  4. All procedure parametersmustbe passed on the runtime stack.Stringsmustbe passed by reference

  5. Prompts, identifying strings, and other memory locationsmustbe passed by address to the macros.

  6. Used registersmustbe saved and restored by the called procedures and macros.

  7. The stack framemustbe cleaned up by thecalledprocedure.

  8. Procedures (except
    main
    )must notreference data segment variables by name.There is asignificantpenalty attached to violations of this rule. Some global constants (properly defined using EQU, =, or TEXTEQU and not redefined) are allowed. Thesemustfit the proper role of a constant in a program (master values used throughout a program which, similar to
    HI
    and
    LO
    in Project 5)

  9. The programmustuseRegister Indirectaddressing for integer (SDWORD) array elements, andBase+Offsetaddressing for accessing parameters on the runtime stack.

  10. Proceduresmayuse local variables when appropriate.

  11. The programmustbe fully documented and laid out according to theCS271 Style Guide

    download
    . This includes a complete header block for identification, description, etc., a comment outline to explain each section of code, and proper procedure headers/documentation.



Notes



  1. For this assignment you are allowed to assume that the total sum of the valid numbers will fit inside a 32 bit register.

  2. We will be testing this program with positive
    and
    negative values.

  3. When displaying the average, you may round down (floor) to the nearest integer. For example if the sum of the 10 numbers is 3568 you may display the average as 356.

  4. Check theCourse Syllabus

    download
    for late submission guidelines.

  5. Find the assembly language instruction syntax and help in theCS271 Instructions Guide

    download
    .

  6. To create, assemble, run,and modify your program, follow the instructions on the courseSyllabus Page’s "Tools" tab.


Resources


Additional resources for this assignment



What to turn in


Turn in a single .asm file (the actual Assembly Language Program file, not the Visual Studio solution file). File must be named "Proj6_ONID.asm" where ONID is your ONID username. Failure to name files according to this convention may result in reduced scores (or ungraded work). When you resubmit a file in Canvas, Canvas can attach a suffix to the file, e.g., the file name may become Proj6_ONID-1.asm. Don't worry about this name change as no points will be deducted because of this.


Example Execution


User input in this example is shown in
boldface italics
.


PROGRAMMING ASSIGNMENT 6: Designing low-level I/O procedures

Written by: Sheperd Cooper

Please provide 10 signed decimal integers.

Each number needs to be small enough to fit inside a 32 bit register. After you have finished inputting the raw numbers I will display a list of the integers, their sum, and their average value.

Please enter an signed number:

156


Please enter an signed number:

51d6fd


ERROR: You did not enter a signed number or your number was too big.

Please try again:

34


Please enter a signed number:

-186


Please enter a signed number:

115616148561615630


ERROR: You did not enter an signed number or your number was too big.

Please try again:

-145


Please enter a signed number:

5


Please enter a signed number:

+23


Please enter a signed number:

51


Please enter a signed number:

0


Please enter a signed number:

56


Please enter a signed number:

11


You entered the following numbers:

156, 34, -186, -145, 5, 23, 51, 0, 56, 11

The sum of these numbers is: 5

The rounded average is: 1

Thanks for playing!
Jun 01, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here