CMSC313, Computer Organization & Assembly Language Programming, Fall 2012
Project 4: External Records
Due: Thursday October 11, 2012, 11:59pm
Objective
The objective of this programming project is to gain experience
writing more complex assembly language programs and to use indexed
addressing modes.
Assignment
Your assembly language program for this project will work with an
externally defined array of records (a.k.a., structs). This array is
defined in a C program as follows:
struct {
char realname[32] ;
char nickname[16] ;
char alignment[20] ;
char role[20] ;
int points ;
int level ;
} records[10] ;
int num_records = 10 ;
The records in the array have pre-initialized values not shown here. The
full text of the C program is available on the GL file system at:
/afs/umbc.edu/users/c/h/chang/pub/cs313/records.c
You need to copy this file into your own directory.
Your assembly language program must search through the array and
find the record with the least number of points and the record with
the highest level. It must then print out the
realname field of these two records. E.g.,
Lowest Points: James Pressman
Highest Level: Gabriel Lee
Implementation Notes
- The sample data in records.c contains 10 records,
but your program should work with any number of records. The number
of records is stored in the int variable num_records.
- In order to access the externally defined array and integer
variable, you must have the following declaration in your assembly
language program:
extern records, num_records
This will allow you to use records and num_records as
labels for the memory location of the array of records and
of the int variable, respectively.
- You must also make your own test cases. The example in
records.c does not fully exercise your program. Your
program will be graded based upon other test cases.
- You will need to link your assembly language program with the
data defined in the C program. Use the following Unix commands:
gcc -c records.c
nasm -f elf report.asm
ld records.o report.o
- An important part of this project is deciding how to use
indexed addressing to access the data in the records. Think this
through carefully. A clean and logical approach to this problem
will yield clean and logical code that is easier to construct and,
more importantly, easier to debug.
- Your program should be reasonably robust and report errors
encountered (e.g., empty array) rather than crashing.
- To access each field of the record, you should use an offset
from the address of the record. You should use %define
constants instead of magic numbers. E.g.,
%define RealnameOffset 0
%define NickOffset 32
%define AlignOffset 48
%define RoleOffset 68
%define PointsOffset 88
%define LevelOffset 92
%define RecSize 96
- When your print out the real names at the end, remember that the
strings in each record are C-style null-terminated arrays of
characters. Before you make a system call asking to print out
the realname field, you must compute the length of the string.
Extra Credit
For 15% extra credit, extend your assembly language program so that it also
prints out the realname field of the record that has the alphabetically
first nickname.
Nicknames should be compared using dictionary ordering. For example, any
string starting with the letter 'a' comes before any string that starts
with 'b' (regardless of length). In the case that one string is a prefix
of another, the shorter string come first. E.g., "egg" comes
before "egghead".
Turning in your program
Use the UNIX submit command on the GL system to turn in
your project. You should submit at least 4 files: your assembly
language program, at least 2 of your own test cases and a typescript
file of sample runs of your program.
The UNIX command to do this should look something like:
submit cs313 proj4 report.asm myrec1.c myrec2.c typescript
Last Modified:
22 Jul 2024 11:28:25 EDT
by
Richard Chang
to Fall 2012 CMSC 313 Homepage