Tasks for 10/25/95

An example

  1. Read and run the example program capitalize.verbose.s .
  2. What happens if you use contractions in a comment?
  3. In the subroutine putstring, what is the role of the two movl instructions? What happens if you remove them? Why?
  4. In the main program, why does prompt get a #, while newline does not?

GDB

  1. Restore the example program to its pristine original state and recompile (that is, reassemble) it. Open up the 68000 intro document and look over the brief reference on gdb.
  2. Start up gdb on your executable version of capitalize.verbose.s.
  3. Examine the first ten instructions in the program (x/10i main should do the trick). To display instructions, gdb has to disassemble the executable--does gdb display exactly the same instructions our source file contained? What happens if you hit the return key at the next prompt?
  4. Examine the characters stored at the label "prompt". Are they what you expected? Are they null-terminated? Where in physical memory does the newline character appear in relation to the prompt string?
  5. Put a breakpoint at the very beginning of the putstring subroutine. Run the program (r). It should suspend execution just before starting the subroutine. What do you expect to see in the registers at this moment? Use i r to see if you were right.
  6. Continue the program (c). Now that you've run through the putstring loop once, what do you expect to see in the registers? Check it out. Do a couple more steps through the loop to see if you've got it figured out.
  7. Try single-stepping through the loop (s), checking the registers in between instructions.
  8. To finish the program without breaking further, use clear to get rid of your breakpoint, and then continue the program.
  9. Do you have questions? Ask me, or try to figure out how to use gdb to answer them yourself.

Work on your assignment

Get to work now on your assignment. I recommend writing and testing atoi, itoa, and getstring in separate files. What's the simplest test of atoi you can imagine? Do you have to have getstring working before you test atoi?



Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057
(507) 663-4364, jondich@carleton.edu