HW_7_sol - What advantages do we have for drawing a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: What advantages do we have for drawing a flowchart before writing a program? Answer: Writing a program can be a complex task involving multiple sub—tasks. A flow—chart provides you with a ’map’ to start, proceed, and complete the necessary tasks. It’s analogous to using an actual street map to find 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 :9}? 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:;§£?£fi£ gigs? STAA RESULT M ‘ DECB _ . BNE MORE w SWI _,_£:f_,,32« ,fir): COUNT EQU $04 m NUMl EQU s10 RESULT RMB $01 ‘ W END , _, as ...
View Full Document

Page1 / 2

HW_7_sol - What advantages do we have for drawing a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online