inclass2.doc

advertisement
CS 210: IN-CLASS PROGRAMMING EXERCISE (27 February 2006)
-------------------------------------------------------BACKGROUND
On our class website is an assembly language application
(named 'add.s') which announces the sum of two unsigned
decimal integers that the user supplies as command-line
arguments. For example, if a user types this command:
$ add 45 23
then the program prints a message saying:
The sum is 68
In order to carry out this computation, the application
must locate the addresses of the two strings of decimal
digits that were typed by the user, convert those strings
to numbers, add the numbers, and then convert the total
into a string of decimal digits for displaying on the
standard output device.
Here the conversions needed for working with the input
and the output are performed by a pair of subroutines
that the programmer can link to his or her program.
These subroutines, contained in our 'base10io.s' file,
are assembled and linked with the application code, like
this:
$ as base10io.s -o base10.o
$ as add.s -o add.o
$ ld add.o base10.o -o add
THE IN-CLASS EXERCISE
Modify the program so that it can add up anm arbitrary
number of unsigned decimal integers supplied by a user
as command-line arguments. (In case no arguments are
given, your revised program should report zero as the
sum instead of printin g an error-message.)
TURN IN a printed copy of your revised program (use
the 'ljpages' utility) with your name included.
COPY TO your '/home/submit/cs210' directory the three
files that you generate: 'add.s', 'add.o', and 'add'.
Download