This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: What advantages do we have for drawing a ﬂowchart before writing a program? Answer: Writing a
program can be a complex task involving multiple sub—tasks. A ﬂow—chart provides you with a ’map’ to
start, proceed, and complete the necessary tasks. It’s analogous to using an actual street map to ﬁnd
a place you have not visited. A map will direct you to perform next actions to reach your destination.
Without it, you may waste time and energy looking for the correct next actions. We
r; If a subroutine comment says “Destroys A, B, and Y,” What instructions must be used before and after the subroutine is executed to preserve the initial values of the accumulators and the Y register? Answer: ' _ The stack is an invaluable tool for temporary storage for cases illustrated in the problem. By storing the
contents of the accumulators to the stack and retrieving them after required instructions are processed,
we can safely restore the accumulator contents. The required instructions before the subroutine are
PSHA, PSI-1B7 and PSHY in that order. The necessary instructions after the subroutine are PULY,
PULB, and PULA, reSpectively. Due to the stack construct (Last—In—First—Out), stack items must be
“pulled” from the stack in the reverse order they were “pushed” on to the stack. g a?» V x, j i W s w , v.
a a: V , , , a. K‘s ‘ V m g E w
, , E; T is , ’ r L 2? 3"“ g 2 was, ORG $0200
LDAA #NUMI £1; E a g m ‘
MORE ADDA #NUMl ,_ ,, ,, ,,s:;§£?£ﬁ£ gigs? STAA RESULT M ‘
DECB _ .
BNE MORE w
SWI _,_£:f_,,32« ,ﬁr):
COUNT EQU $04 m
NUMl EQU s10
RESULT RMB $01 ‘ W END , _, as ...
View Full Document
This note was uploaded on 06/08/2009 for the course ECE 331 taught by Professor M.shanblatt during the Spring '08 term at Michigan State University.
- Spring '08