Machine Problem 2, due September 27
Part of
the homework for 22C:60, Fall 2008
|
Submit the source file mp2.a
for your solution using the submit command, documented at:
--
http://www.divms.uiowa.edu/help/msstart/submit.html
Before you begin work on your solution, take the working hello-world program from chapter 5 of the notes, assemble it and run it. This does not involve any programming, just transcribing the code from the notes into file, for the sake of example, call it hello.a, and then assembling it with the smal hello.a, linking the result with link hello.o and then running it with hawk link.o.
Modify the hello-world program so the output text is your name, and so that the text is centered in the output area of the screen. Also, of course, you should modify the program so that the comments and title at the head of the program say that it is mp2, with you as the author.
Note that your program will have to use the screen height and width returned by the call to DSPINI at the start of the program, and your program will have to call DSPAT to set the position of the output before calling DSPST to output your name.
If the program was being written in a high level language, it might look something like this:
name = "Percival Prescott Philbert"; [ width, height ] = dspini(); dspat( (width-length(name))/2, height/2 ); dspst( name );
Reading the notes, you will find a discussion of how to use the
assembler to compute the length of a name in Chapter 3. You can
use an add-immediate instruction to subtract a constant
from a register. Chapter 13 of the Hawk Manual describes
how to divide by various constants, including the constant 2. The
instruction it uses for this is documented in Chapter 6 of the
manual
If your program runs correctly, the output should be a
obviously correct, your name reasonably well centered in the
emulator's display area. You can increase your confidence that
the program is running by exiting the emulator, resizing the
terminal window and then re-running the emulator. The text
should still be centered.
Grading Critereia