Tasks for 10/25/95
An example
- Read and run the example program
capitalize.verbose.s .
- What happens if you use contractions in a comment?
- In the subroutine putstring, what is the role of
the two movl instructions? What happens if you remove them?
Why?
- In the main program, why does prompt get a #, while
newline does not?
GDB
- 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.
- Start up gdb on your executable version of capitalize.verbose.s.
- 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?
- 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?
- 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.
- 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.
- Try single-stepping through the loop (s), checking the registers
in between instructions.
- To finish the program without breaking further, use
clear to get rid of your breakpoint, and then continue the
program.
- 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