I have been struggling on this question for some time and need require some help.
This question is based on the EASY68K simulator processor. Use the T121 Processor Instruction Set of the EASY68K simulator to answer the following questions.
Rewrite the program in Figure Q3 to include a subroutine to add a series of integers. The subroutine should perform the functions of the loop. The subroutine occupies memory space just below the main program. Use SUM as the subroutine address label.
FIGURE Q3
ORG $1000
START MOVE #$2000,A0
MOVE.B #$08,D0
MOVE.L #$0,D1
LOOP ADD.B (A0)+,D1
SUB.B #$01,D0
BNE LOOP
LSR #$03,D1 ; Logical Shift Right by 3 places
MOVE.B D1, $2050
STOP #$2700
Initialise and use test data: 1, 2, 3, … up to the loop counter deduced in Question 3(b). Assume the contents of all data registers are set to zero before the start of the program.
Here is my working. I'm not sure if I'm doing it right as I don't understand how to tackle this question.
ORG $1000
START MOVE #$2000,A0
MOVE.B #$08,D0
MOVE.L #$0,D1
BSR SUM ;BRANCH SUMBROUTINE
STOP #$2700
SUM ADD.B (A0)+,D1
SUB.B #$01,D0
BNE SUM
LSR #$03,D1 ; Logical Shift Right by 3 places
MOVE.B D1, $2050
RTS
ORG $2000
DATA DC.B $1,$2,$3,$4,$5,$6,$7,$8 ; Define constant.
END START