LD03: Arrays and Text Files due Thu 03 Oct 13:20

Purpose

In this assignment you will learn/practice:

Preparation for Lab Day

Get the most recent version of the homework/labday repository. In the ld03 directory you should have a program called arraystarter.asm. Edit that file and follow the instructions provided in the comments. Once you have completed the instructions commit your solution and push to bitbucket.

Lab Day

  1. At the beginning of the period show your prep work to the instructor will examine your prelab work from you repository. You can go ahead and start working on the following steps.

  2. With a text editor, open lib/iomacros.asm and read the documentation for the commands: fopenr, fget_i, and fclosem.

  3. Do this and the remainining steps in the ld03 directory of your repository. With a text editor create a document called numbers.txt and type in 10 different numbers (one per line).

  4. Add code to your arraystarter.asm program so that it opens and closes the text file you just created. Use dump_regs to verify that RAX contains what you expect.

  5. Between the open and close commands add a command to read a single integer from your file. Display the integer you read.

  6. Add a loop so that you read 10 numbers from the file and display them as they are read.

  7. Modify the data file so that it contains 11 numbers. Is your program stopping at 10? If so, rewrite the code so the program stops reading at the end of the file rather than a fixed number.

  8. Create an array in memory big enough to hold up to 100 integers.

  9. Modify your loop so that values you read from the file are stored into the new array.

  10. After the file is closed, write a separate loop that will traverse the array and display the numbers.

  11. Show your completed work to the instructor.

  12. If you finish early, work on your homework assignment until the end of the lab period.

Assembly Language

Segmentation Fault Counter

1779740142