Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question #9 (10 pts) examination book.) Write a program in 68K assembly language

ID: 2267832 • Letter: Q

Question

Question #9 (10 pts) examination book.) Write a program in 68K assembly language that will reverse write your answer on this sheet. Begin your solution on a new page in location $00004000 the word contents of memory through $00004013, inclusive. For example, the word in memory location d with the word in memory location $00004012. The word in memory with the word in memory location $00004010. And so forth 2 i an This is a real program that is being designed to run in the 68K simulator. You programming form, including a header block and comments. should use proper The pcb layout for problem #2 is located on the last sheet of this examination. You may tear it out if you wish, but you must return it with the exam when you are done.

Explanation / Answer

1). Below code exchange contents in memory location $00004000 to $00004013

2). Each word occupie two byte locations

3). Input data : 1,2,3,4,5,6,7,8,9,10 ($4000 to $4012)

4). Output from after executing below code is 10,9,8,7,6,5,4,3,2,1

*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
ORG $00004000
WORD_ARRY DC.W 1,2,3,4,5,6,7,8,9,10
WORD_STRT EQU $00004000
WORD_END EQU $00004012
WORD_LEN EQU 10 ;Total 10 words.

ORG $1000  
START:   
MOVEA.L #WORD_STRT,A0 ;WORD MEMORY STARTING LOCATION
MOVEA.L #WORD_END,A1 ;WORD MEMORY ENDING LOCATION
MOVE.L #WORD_LEN,D3 ;Legnth of the word array
LSR.L #1,D3 ;Divide by 2, for swapping counter, D3 = 5
SUB.L #1,D3 ;Loop counter should be 0 to 4 i.e. length 5, D3 = 4
  
LOOP: MOVE.W (A0),D1 ;Read from starting location
MOVE.W (A1),D2 ;Read from ending location
MOVE.W D2,(A0)+ ;Write End words from starting
MOVE.W D1,(A1)
SUBQ.L #2,A1
  
DBEQ D3,LOOP
  
HALT_CODE: JMP HALT_CODE
  
END START ; last line of source