HW05: Arrays and Text Files due Mon 07 Oct 23:59

Purpose

This assignment give students practice in reserving, initializing, and traversing arrays in assembly language. It also introduces use of the I/O macros that facilitate reading from a file.

Allowed and Disallowed Resources

In completing this assignment you MAY use/access the following resources:

You may NOT use/access:

Failure to abide by these guidelines will result in a zero for the assignment and the incident will be reported to the university provost as a violation of the university academic integrity policy. A second incident of academic dishonesty (whether from this course or another computer science course) will result in an F in the course.

Overview

You will write two programs: array_int.asm and array_str.asm. The programs will read data from provided input files named numbers.txt and names.txt, respectively, store the data into arrays, and then traverse the arrays.

Begin by pulling the most recent version of the homework repository and do your work in the hw05 directory. The required input files are found in the data directory of the repository. Also recall that you can find sample code that uses the I/O macros to read from a data file (in the demos directory of the repository).

First Program: array_int.asm

Write an x86 assembly program that will read the integer values from numbers.txt and store them in an array. IN A SEPARATE LOOP, after the numbers have been stored into the array, traverse the array and calculate the average value (using integer division), the minimum value, and the maximum value. The output of your program should include these three values along with the name of the input file and the number of integers read from the file.

You may assume that the file contains no more than 10,000 numbers and that the numbers are signed and will fit in a range appropriate for 32-bit signed values. The input file will have exactly one integer value per line. The numbers may be positive or negative (and the average can therefore be negative ... take a look at the commands cdq, cwd, cbw).

NOTE: I am fully aware that the program can be written more efficiently without storing the values into the array. However, the point of the assignment is for you to practice using arrays in a simple environment.

Second Program: array_str.asm

Write an x86 assembly program that will read string values from names.txt and store them in an array. IN A SEPARATE LOOP, after the names have been stored into the array, traverse the array and display all the names that have 20 or more characters in them.

The fget_str IO macro returns the length of the read string in EAX. You can either store the lengths in a parallel array as you read in the names or you can recalculate the string lengths in the following loop. To determine the length of the string move one character at a time through the string counting as you go, stopping when to reach the zero byte.

You may assume that the file contains no more than 10,000 names and that no name will be longer than 26 characters. The input file will have exactly one name per line. There is no need to try to separate first and last name in this assignment.

Submission Guidelines

Push all required work to your bitbucket repository prior to the due date/time.

Assembly Language

Segmentation Fault Counter

1779736930