CH3 - Decrements A PSHX Pushes X onto the stack LDAB 0,X...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Rick Wagoner IET645 – Spring 2006 Chapter 3 Exercises E3-1. Write an instruction sequence to set up the top six bytes of the stack as follows: SP → $41 $42 $43 $44 $45 $46 LDAA $46 Loop PSHA DECA CMPA $40 BNE Loop SWI E3-2. Write an instruction sequence to load the tenth element (associated with index 9) of an array into Accumulator A. The base address of the array is ARR. The first element is associated with index 0. ORG $00 ARR FCB 0,1,2,3,4,5,6,7,8,9 LDX #ARR LDAA 9,X E3-9. The label ARR is the starting address of an array of twenty-five 8-bit elements. Trace the following code sequence and describe what the subroutine TESTSUB does. LDX #ARR LDAA #25 BSR testsub . . . Testsub PSHA Pushes A onto the stack. DECA
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Decrements A PSHX Pushes X onto the stack LDAB 0,X Loads initial array element into B INX Increments X again CMPB 0,X Compares B to the next element of the array BLE Branches to next if B is less than or equal to currently selected array location LDAB 0,X Loads the current array value into B if branch not taken next INX Increments X DECA Decrements A BNE again Branch to again if A is not 0 PULX Pulls X from stack if branch is not taken PULA Pulls A from stack RTS Return to point following subroutine call The primary purpose of this subroutine is to locate the largest value in the array and return it upon completion....
View Full Document

Ask a homework question - tutors are online