View the step-by-step solution to:

Question

# How modify the code on lines 35 through 39 to take into account that each array element is 4 bytes rather than a

single byte

* Description: Indirect with index and displacement :program starts at \$8000
EQU :start of data
EQU :number of columns in matrix ORG
' Prompt user to enter row number (0-3) START: LEA HSGlJLl :31 points to H561
BOULB \$14.00 :display string
TRAP #15 :system call.
MOVE.B “.00 :read row number from keyboard into 01 #15 :system call.
.I. 01.02 :save row number * Prumpt user to enter column number (0-3) LEA H\$G2.A1 :A0 points to H561 HOVE.B \$14.00 :display string TRAP #15 :system call. HOVEJ “.00 :read column number from keyboard into 01 #15 : system call
01. D3 l—IWI—l——&quot;

EASy68K Editor/Assembler v5.16.01 - [Lab3n.X68]
File Edit Project Options Window Help
D
Load array element at matrix [row] [column]
CLR
D4
Line 35 - 39
LEA
MATRIX, AO
:A0 points to base of array
MULU
#NCOLS , D2
; compute row x NCOLS
D2 , D3
MOVE. B 0 (A0, D3 . L) , D4
Display array element on console
CLR. L
D1
; clear Dl
MOVE . B
D4, D1
; move array element to DI
LEA
MSG3, Al
:10 points to MSG1
MOVE . B
#14, DO
; display string
TRAP
#15
; system call
MOVE . B
#3, DO
; display array element
TRAP
#15
; system call
SIMHALT
;halt simulator
Statically allocate 4 x 4 matrix
ORG
DATA
MATRIX
DC . B
0, 1,2,3
; store 2-dimensional array
DC . B
4,5,6,7
DC . B
8, 9, 10, 11
DC. B
12, 13, 14, 15

NOPO
1
2
MATRIXij =
5
6
7
9
10 11
12 13 14 15
Once running, the program prompts the user to enter a row number i and a column
number j. (Both i and / should be in the range of 0 to 3.) The program then displays
MATRIX [i] [j] - the value of the byte at row i and column j, as shown below.
Sim58K V/O
X
Enter row (0-3)- 2
Enter column (0 3)
Array Element:
Step 4
Run the program multiple times, each time trying different values for i and j. Make sure
you understand how the program functions, before proceeding.
Step 5
Using the previous program as a starting point, modify the program so that each matrix
element is now a long word rather than a byte. Then, update the program so that it works
correctly with long words. (Note: You do not have to change the input and output code -
it will continue to function correctly.) You will need to modify the code on lines 35
through 39 to take into account that each array element is 4 bytes rather than a single byte.
Save the new program under the file name Lab30.X68. [20 points]

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents