McGraw_Hill_Contemporary_Programming_and_Software_Design_Binder_2_Modules_6_to_10.pdf

(50530 KB) Pobierz
3939 Wisconsin Avenue
Washington. D.C. 20016
Telephone
202
/244·
1600
Enclo
sed
is
Module
6
. . .
Te
s
tin
g
and Debugging Made Easy
In your previous module
.
you examined
what
is
referred to
as
the internal
programming
"MAP"
of several different
processors.
coded
programs
in assembly
language and
reviewed different addressing modes.
tn this module we will show
you
how to test and
debu
g compu
t
er pr
og
rams
.
Learning
to debug a program
is esse
ntial.
particularly
if the program
is
new
or
you are modifying a large program
.
Very seldom does anyone
design
or
modify a
program
w1th going through one
or
more
test
and debugging
routine
s
.
The module begins with a discussion of the most common type
of
errors
encountered in programming and shows you how
they
work their
way
lnto
programs
.
We then review the procedures used to
find
the various types
of
errors
.
Locating
and correcting
program
errors
is
usually done in
two
stages
:
*
Fir
st
. we
locate spelling and
syntax
errors
so
the
program will
compile or
assemble correctly
Now.
we
can
run the
resulting machine
lan
gua ge
pr
og
ram
and
test it for logi-
cal errors
.
*
Next. we show you how
the debugging process can be made
easier and
more
certain by trcating the program as
a se
ries
of
functio
nal
blocks and
testing
each
block
by
itself. and then 1n conjunction
with
adjoining blocks. This
meth
od
allows you
to
make sure
each
block is (ully
test
ed
and errors corrected.
even
if
the
effect of each block is not
easily recognized
on
the
screen.
To help you understand the way and
how
of
debugging.
we have included
some
pr
ograms
on the
enclosed
disk that you will examine
and
modify
using
your
"
NRIBUG" program
.
Your
next module.
"Creating
l-leaningful
Documentation"
will
illustrate
how
a
few
hours of
writing
clear documents
when
the
pr
og
r
am
is designed. will
save
you hours
of
work
at somc
later
date
.
when
you try to
modify the design of
an
exis
t
ing program
.
\o,le
also
will
covcr
the dif
fe
rent types
of
documentation
as
well
as
proven
shortcuts
.
Learn how to prevent making the most common error
ade in programming
-
- bad
or
miSSing documenta
t
ion
.
m
Sincerely
yours
.
~/~
Kenneth
J
.
Bigelow
Project Engineer
LR
815(801)
Overview
for
the
Commodore
64 and
128
Computers
CONTEMPORARY
PROGRAMMING
AND SOFTWARE
DESIGN SERIES
With
Module 6,
you begin
the
second
half of
your
course in
Contemporary
Programming
a
nd
Soft·
ware Design.
In
the
first half
of
the
Series,
you
followed
the development
process
of a
computer
program from the initial idea
or problem,
through
the
development
of
the
solu
tion procedure, and up
to the
coding of
the
actual computer program.
However,
as you write
programs
of your
own,
you
will
find that they
seldom
perform
exactly as
intended the
very
first time they
are
run.
In
fact
,
you
might
be
surprised
at
the number
of
tests and
corrections we must
make in
our
example programs
on
the
program
disks
enclosed
with
each
module in
this series!
Errors
appear for
many
reasons and
have
a number
of causes.
They
must be
eliminated
one
by
one
from a
program,
until that
program
work
s correctly
in
all
respects.
In
this
module
,
you
will
become
familiar with
many kinds
of errors
that may appear
in
programs
of
all
kinds.
Some
of
these
errors are
obvious
and
easily spotted, as soon as the
intepreter
or compiler
reaches
them.
Syntax
errors or
illegal uses
of
operators
or variable
names will
be called
out
very
quickly.
Other
errors are
very subtle.
They
only
show up after much searching
and
testing.
Reversed
logic in
a
mathematical
calculation
,
for example, is
perfectly legal and witl
run
as writt en.
However,
it
will
still give wrong answers
to
the
problem. This
sort
of
error
usually requires
that
you
trace through
the program
one
step a
t
a
time,
comparing
the
comput er's
performance with your
manual
solution.
As
with
all of
the
program
disks
you
have received
so far, the
enclosed
disk is
fo
rmatted for the
Commodore
64
and
128
(in
64
mode)
computers.
We
suggest
that you
use
UNI-COPY
or
BACKUP
to duplicate this disk
, and
then
use
the
backup
copy
with Ihis mod ule.
Then,
in
case
of an accident, you
will
still
have the
original disk and
can
m"ke
another
copy.
You
will
also
need
either
NRIBUG
or
the
Fast
Assembler
from
Module
5.
You
will
be modifying a
number
of
programs
using
these
ut
ilities.
Now,
to
begin
working with
this
11l0du/e.
turn
0
11
yotlr
disk
driue(s)
and
computer,
alld
type
in
the
commands:
LOAD
"
WELCOME"
.8<
t'ClUm>
RUN<
retum>
When
the program
direc
ts you
to
do
so,
open
your
Learning
Guide
to the
Introduction.
You
are
now
dealing
with one of
the
most
important
aspects of
computer programming:
debugging.
N,
MODULE 6
es
816
e(SOH
FOR THE COMMODORE 64
AND 128 COMPUTERS
TABLE OF CONTENTS
TESTING AND DEBUGGING MADE EASY
Introduction
.
........
.
...........................
.
..
.
.
.
....................
1
Track 1:
How Errors
Appear in
Programs
..
.
..............
.
.
.
.
.
•..
.
.
••
.
......
3
Tra
ck
2: Locating
and Correcting
Errors in
a
Program,
Part
1
........•.....•.......
7
Tra
ck
3
:
Locating
and correcting
Errors, Part
2
..............
.
....•......
.
.
....
11
Track
4: Patching Errors
in
Compiled Code .......
.
...
.
.
.
..
.
.....
.
...
.
........
19
Track 5
:
Simplifying
the Debugging Process
..........•.....•
.
....
.
....
.
.
....
27
Track
6
:
Practice Problems.
.
. . . .
.
. .
. .
. .
.
. . . .
.
. . . .
.
. .
.
.
. .
.
.
. .
.
. . • . . . .
.
.
.
.
. .
35
MODULE6
McGraw·HIII Continuing Education Center
3939 Wisconsin Avenue
Washington, D.C.
20016
Copyright 1988 by McGraw-Hili, Inc. All rights reserved. Manufactured in the United States of America. Except as
permitted under the United States Copyright Act of 1976, no part of this package may be reproduced or distributed in
any form or by any means, or stored in a data base or retrieval system, without the prior written permission of the
publisher.
0·07·580084·5
MODULE 6
Zgłoś jeśli naruszono regulamin