Question: 4. Hand assemble the following code. Briefly explain (but in detail) the function of this code ORG LDX LDAA STAA $0 #$1000 ;pointer to data

 4. Hand assemble the following code. Briefly explain (but in detail)

4. Hand assemble the following code. Briefly explain (but in detail) the function of this code ORG LDX LDAA STAA $0 #$1000 ;pointer to data #$10 ;counter value $1100 counter will be saved in memory to free up a CPU register ;assembler directive (origin) to tell where code will be placed in memory LOOP: LDAA get 1st data value $10,X get 2nd data value LDAB SUM AB SHFB R STAB INX LDAB LDAA SUM BA BEQ STAA BNE data1 data2 divide sum by 2 $20,Xstore ave. value #$FF $1100 increment pointer ;-1 in 2's complement format ;count = count-1 DONE branch to done if count is zero $1100 ;else, save counter value LOOP and repeat loop DONE loop forever DONE: BEQ Why do we have to save the counter value in memory during each pass of the loop? How many times (decimal) will the loop execute? 4. Hand assemble the following code. Briefly explain (but in detail) the function of this code ORG LDX LDAA STAA $0 #$1000 ;pointer to data #$10 ;counter value $1100 counter will be saved in memory to free up a CPU register ;assembler directive (origin) to tell where code will be placed in memory LOOP: LDAA get 1st data value $10,X get 2nd data value LDAB SUM AB SHFB R STAB INX LDAB LDAA SUM BA BEQ STAA BNE data1 data2 divide sum by 2 $20,Xstore ave. value #$FF $1100 increment pointer ;-1 in 2's complement format ;count = count-1 DONE branch to done if count is zero $1100 ;else, save counter value LOOP and repeat loop DONE loop forever DONE: BEQ Why do we have to save the counter value in memory during each pass of the loop? How many times (decimal) will the loop execute

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!