0% found this document useful (0 votes)
18 views

Memory Address Solutions

The document contains examples of calculating addresses in row-major and column-major ordering for multi-dimensional arrays. The examples show calculating the base address and using formulas to find the address based on index values, array bounds, row and column sizes, and byte width.

Uploaded by

Sudhir Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Memory Address Solutions

The document contains examples of calculating addresses in row-major and column-major ordering for multi-dimensional arrays. The examples show calculating the base address and using formulas to find the address based on index values, array bounds, row and column sizes, and byte width.

Uploaded by

Sudhir Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1) ) Given, Address of ARR[3] [6] = 1430

According to row-major,
Address = B + w(n(p – L1) + (q – L2)
B = 1430, w = 4 bytes
p = 3, q = 6,U1 = 6, U2 = 8, L1 = -4, L2 = 3
Number of columns n = U2 – L2 + 1
⇒n=8–3+1=6
Address of ARR[3][6] = 1430 + 4(6 (3 – (-4))+
(6 – 3))
= 1430 + 4(6 × 7 + 3)
= 1430 + 180
= 1610
2) Base Address, B = 1500
W = 4 Bytes
i = 4, j = 5, r = 1, c = 1
Formula for Column Major Wise
A[4][5] = B + W[m(j – c) + (I – r)]
1608 = 1500 + 4[m(5 – 1) + (4 – 1)]
1608 – 1500 = 16m + 12
16m = 96
m=6
3) 1400 is base address, column =10, W = 8
bytes, i = 10, j = 7, Ir = 0 and Ic = 0.
Address of P[10] [7]:
= 1400 + 8[(10 – 0)*10 + (7 – 0)]
= 1400 + 8[100 + 7]
= 1400 + 8*107
= 2256
4) D [-2… 10] [3 …8]
BaseAddress B = 4110
I = 4, J = 5
D [4] [5] = ?
W = 8 bytes
M = 10
Columnwise
= 4366
5) AR [-4,… 6, -2 … 12]
Row- wise order,
AR[2] [3] = B + W(n(i-1)+(j-1))
Given i = 2, j = 3, W = 2 bytes
B=?
n = Uc – Lc + 1
= 12 – (-2) + 1
= 12 + 2 + 1
= 15
Now, 414 = B + 2 [15 (2 -(-2)) + (3-(-4))]
B + 2[60 + 7] = 4142
B + 134 = 4142 or B = 3952
6) Row Major address formula:
M[i] [j] = BA+W [(i – Ir) * column + (j – Ic)]
BA: 1840, Ir = 0, Ic = 0, W = 4, rows = 10,
column = 10, i = 4, j = 8
M[4] [8] = 1840 + 4 [(4 – 0) × 10+ (8 – 0)]
= 1840 + 192
= 2032
7) Given
i = 10, j = 7, w = 2, B = 1012
r = 10, w = ?
Add [i][j] = 1060
Colomn wise
Add [i][i] = B + [(J – Lc) + (I – Lr)]
⇒ 1060 = 1012 + [(3 – 1) * 10 + (7 – x)] * 2
⇒ 1060 – 1012 = 2 [(7 – x) + 20]
⇒ 48 = 2[(7 – x) + 20]
⇒7–x=4
⇒x=7–4=3
8) B = 1098, W = 2, n = m
1144 = 1098 + 2 [m(5 – 1) + (4 – 1)]
⇒ 1144 = 1098 + 8m + 6
⇒ 8m = 40
⇒m=5
9) B + W [(I – LBR) + M (J – LBC)]
= 1046 + 2 [(2 – 0) + 7(3 – 0)]
= 1046 + 2(2 + 21)
= 1046 + 2(23)
= 1046 + 46
= 1092

You might also like