In this assignment you will learn/practice:
- how to work with structured data
- how to work with an array of structured data
- reading homework instructions
Do these steps to get ready for lab day:
- Make sure you have the latest version of the homework repository
and do your work in the provided hw06 directory.
- Read the “Overview” section of the homework assignment:
http://josephus.sergeantservices.com/classes/al/homework/hw06
- Copy your
array_str.asm file from the previous assignment into
the folder and name it sumo.asm
- Take a moment to view the data/sumo.txt in the repository.
- Copy sumo.txt into a file called short.txt and in that new
file remove all but the first 5 lines. You will use this file for initial
testing of your program.
- On paper write out the size of a single struct/class that will hold a
rank, a height, a weight, and a name based on the problem description.
Calculate (and write) the offset of each piece of the struct. Then
write a declaration you will put in the .bss section
On lab show your paper calculations and show the hw06 directory you
created.
- At the beginning of the period show your prep work to the instructor.
You will continue work in your hw06 folder.
- Modify sumo.asm to comment out most of the existing executable
section and modify it as follows.
- At the top of the program (after
%include) use %define to
assign names (all caps) to the offsets you calculated above. Also define a
value for RECSIZE which will hold the size of an entire record
(three numbers and a string).
- Add code to reserve space for an array big enough to hold 100
sumo records based on your calculations (100*RECSIZE).
- Add code to open the small.txt file and read the first entry
(as 3 signed 32-bit ints and one string). Store the data in the first
slot of the array.
- Print the data you read from the file using the offsets you
defined.
- NOTE: after reading the 3rd number and then reading the string
you will find that the string contains a space at the beginning
because there was a space leftover after reading the 3rd number.
Add a
get_ch statement prior to your get_str to
read the extra space.
- Have the instructor give you feedback on what you have done so far.
- Modify your source code so it uses a loop to read 5 entries from the
file and into the array in consecutive slots. It is okay to initially
hardcode the number of entries to read.
- Modify your source code so it prints 5 entries from the array.
- Show your completed work to the instructor.
- If you finish early, work on your homework assignment until the end of
the lab period.